database-wrapper-pgsql 0.2.36__py3-none-any.whl → 0.3.146__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- database_wrapper_pgsql/__init__.py +1 -1
- database_wrapper_pgsql/connector.py +32 -22
- database_wrapper_pgsql/db_wrapper_pgsql_mixin.py +3 -2
- {database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.3.146.dist-info}/METADATA +10 -9
- database_wrapper_pgsql-0.3.146.dist-info/RECORD +13 -0
- {database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.3.146.dist-info}/WHEEL +1 -1
- database_wrapper_pgsql-0.3.146.dist-info/licenses/LICENSE +21 -0
- database_wrapper_pgsql-0.2.36.dist-info/RECORD +0 -12
- {database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.3.146.dist-info}/top_level.txt +0 -0
|
@@ -397,7 +397,10 @@ class PgsqlWithPooling(DatabaseBackend):
|
|
|
397
397
|
max_lifetime=20 * 60,
|
|
398
398
|
max_idle=400,
|
|
399
399
|
timeout=self.connection_timeout,
|
|
400
|
-
|
|
400
|
+
# Validate connections on checkout and keep retrying to refill broken
|
|
401
|
+
# ones, so a transient DB/network stall can't permanently wedge the pool.
|
|
402
|
+
reconnect_timeout=300,
|
|
403
|
+
check=ConnectionPool.check_connection,
|
|
401
404
|
num_workers=4,
|
|
402
405
|
connection_class=PgConnectionType,
|
|
403
406
|
kwargs=self.config["kwargs"],
|
|
@@ -516,12 +519,14 @@ class PgsqlWithPooling(DatabaseBackend):
|
|
|
516
519
|
) -> tuple[PgConnectionType | None, PgCursorType | None]:
|
|
517
520
|
"""Context manager"""
|
|
518
521
|
|
|
519
|
-
#
|
|
520
|
-
|
|
521
|
-
|
|
522
|
+
# Connections are kept in a per-context stack so that nested
|
|
523
|
+
# context managers each get and return their own connection.
|
|
524
|
+
# A failed connection pushes None to keep push/pop balanced.
|
|
522
525
|
res = self.new_connection()
|
|
526
|
+
stack = self.context_connection.get() or ()
|
|
527
|
+
self.context_connection.set(stack + (res,))
|
|
528
|
+
|
|
523
529
|
if res:
|
|
524
|
-
self.context_connection.set(res)
|
|
525
530
|
return res
|
|
526
531
|
|
|
527
532
|
return (
|
|
@@ -532,12 +537,12 @@ class PgsqlWithPooling(DatabaseBackend):
|
|
|
532
537
|
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
|
|
533
538
|
"""Context manager"""
|
|
534
539
|
|
|
535
|
-
|
|
536
|
-
if
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
540
|
+
stack = self.context_connection.get() or ()
|
|
541
|
+
if stack:
|
|
542
|
+
entry = stack[-1]
|
|
543
|
+
self.context_connection.set(stack[:-1])
|
|
544
|
+
if entry:
|
|
545
|
+
self.return_connection(entry[0])
|
|
541
546
|
|
|
542
547
|
####################
|
|
543
548
|
### Transactions ###
|
|
@@ -687,7 +692,10 @@ class PgsqlWithPoolingAsync(DatabaseBackend):
|
|
|
687
692
|
max_lifetime=20 * 60,
|
|
688
693
|
max_idle=400,
|
|
689
694
|
timeout=self.connection_timeout,
|
|
690
|
-
|
|
695
|
+
# Validate connections on checkout and keep retrying to refill broken
|
|
696
|
+
# ones, so a transient DB/network stall can't permanently wedge the pool.
|
|
697
|
+
reconnect_timeout=300,
|
|
698
|
+
check=AsyncConnectionPool.check_connection,
|
|
691
699
|
num_workers=4,
|
|
692
700
|
connection_class=PgConnectionTypeAsync,
|
|
693
701
|
kwargs=self.config["kwargs"],
|
|
@@ -819,12 +827,14 @@ class PgsqlWithPoolingAsync(DatabaseBackend):
|
|
|
819
827
|
) -> tuple[PgConnectionTypeAsync | None, PgCursorTypeAsync | None]:
|
|
820
828
|
"""Context manager"""
|
|
821
829
|
|
|
822
|
-
#
|
|
823
|
-
|
|
824
|
-
|
|
830
|
+
# Connections are kept in a per-context stack so that nested
|
|
831
|
+
# context managers each get and return their own connection.
|
|
832
|
+
# A failed connection pushes None to keep push/pop balanced.
|
|
825
833
|
res = await self.new_connection()
|
|
834
|
+
stack = self.context_connection_async.get() or ()
|
|
835
|
+
self.context_connection_async.set(stack + (res,))
|
|
836
|
+
|
|
826
837
|
if res:
|
|
827
|
-
self.context_connection_async.set(res)
|
|
828
838
|
return res
|
|
829
839
|
|
|
830
840
|
return (
|
|
@@ -835,12 +845,12 @@ class PgsqlWithPoolingAsync(DatabaseBackend):
|
|
|
835
845
|
async def __aexit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
|
|
836
846
|
"""Context manager"""
|
|
837
847
|
|
|
838
|
-
|
|
839
|
-
if
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
848
|
+
stack = self.context_connection_async.get() or ()
|
|
849
|
+
if stack:
|
|
850
|
+
entry = stack[-1]
|
|
851
|
+
self.context_connection_async.set(stack[:-1])
|
|
852
|
+
if entry:
|
|
853
|
+
await self.return_connection(entry[0])
|
|
844
854
|
|
|
845
855
|
####################
|
|
846
856
|
### Transactions ###
|
|
@@ -2,7 +2,7 @@ from typing import Any
|
|
|
2
2
|
|
|
3
3
|
from psycopg import sql
|
|
4
4
|
|
|
5
|
-
from database_wrapper import NoParam, OrderByItem
|
|
5
|
+
from database_wrapper import NoParam, OrderByItem, RawSQL
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class DBWrapperPgsqlMixin:
|
|
@@ -72,7 +72,8 @@ class DBWrapperPgsqlMixin:
|
|
|
72
72
|
|
|
73
73
|
order_list = [
|
|
74
74
|
sql.SQL("{} {}").format(
|
|
75
|
-
|
|
75
|
+
# RawSQL keys are trusted expressions; Identifier would quote them as one name
|
|
76
|
+
sql.SQL(item[0]) if isinstance(item[0], RawSQL) else sql.Identifier(item[0]),
|
|
76
77
|
# order_direction (from DBWrapperMixin via MRO) validates against ASC/DESC
|
|
77
78
|
sql.SQL(self.order_direction(item)), # type: ignore[attr-defined]
|
|
78
79
|
)
|
{database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.3.146.dist-info}/METADATA
RENAMED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper_pgsql
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.146
|
|
4
4
|
Summary: database_wrapper for PostgreSQL database
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
|
-
License:
|
|
7
|
-
Project-URL: Homepage, https://github.com/
|
|
8
|
-
Project-URL: Documentation, https://github.com/
|
|
9
|
-
Project-URL: Changes, https://github.com/
|
|
10
|
-
Project-URL: Code, https://github.com/
|
|
11
|
-
Project-URL: Issue Tracker, https://github.com/
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/4Apps/py_database_wrapper
|
|
8
|
+
Project-URL: Documentation, https://github.com/4Apps/py_database_wrapper
|
|
9
|
+
Project-URL: Changes, https://github.com/4Apps/py_database_wrapper
|
|
10
|
+
Project-URL: Code, https://github.com/4Apps/py_database_wrapper
|
|
11
|
+
Project-URL: Issue Tracker, https://github.com/4Apps/py_database_wrapper/issues
|
|
12
12
|
Project-URL: Download, https://pypi.org/project/database_wrapper/
|
|
13
13
|
Keywords: database,wrapper,python,postgresql,pgsql
|
|
14
14
|
Classifier: Development Status :: 4 - Beta
|
|
15
15
|
Classifier: Intended Audience :: Developers
|
|
16
|
-
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
17
16
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
18
17
|
Classifier: Operating System :: Microsoft :: Windows
|
|
19
18
|
Classifier: Operating System :: POSIX
|
|
@@ -32,9 +31,11 @@ Classifier: Topic :: Software Development
|
|
|
32
31
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
32
|
Requires-Python: >=3.8
|
|
34
33
|
Description-Content-Type: text/markdown
|
|
35
|
-
|
|
34
|
+
License-File: LICENSE
|
|
35
|
+
Requires-Dist: database_wrapper==0.3.146
|
|
36
36
|
Requires-Dist: psycopg[binary]>=3.2.0
|
|
37
37
|
Requires-Dist: psycopg[pool]>=3.2.0
|
|
38
|
+
Dynamic: license-file
|
|
38
39
|
|
|
39
40
|
# database_wrapper_pgsql
|
|
40
41
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
database_wrapper_pgsql/__init__.py,sha256=39bGD6dItHeX9-AUwGvsmMJz05LJcrS7sw1JaNPUJ4M,1162
|
|
2
|
+
database_wrapper_pgsql/connector.py,sha256=Dr_S0aD1SjfsTuCma1zQocSJSwWKOoePuR0fcEGM8r4,27993
|
|
3
|
+
database_wrapper_pgsql/db_wrapper_pgsql.py,sha256=lrMN9lqfS0JapEfNu2sFeFxifK67eBhZZebU3MpvnRk,1909
|
|
4
|
+
database_wrapper_pgsql/db_wrapper_pgsql_async.py,sha256=cYYyBFWvVG3e24Ik0mJXnbxic9bskqnB-K3hEbJ6pk8,2025
|
|
5
|
+
database_wrapper_pgsql/db_wrapper_pgsql_mixin.py,sha256=pFAG6dX1_fjuDDKk0XSBxmBKwg6_w3KFbmf8M2JRxm4,5692
|
|
6
|
+
database_wrapper_pgsql/pg_introspector.py,sha256=-9_tTxOG7778gxaGuhsxcbCN42mEjr9kG-EAegxsU74,2684
|
|
7
|
+
database_wrapper_pgsql/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
database_wrapper_pgsql/type_mapping.py,sha256=KWIAT78Z6h5DEt8uQNfQP6t5ahBUPuLKgcPfQmIywM4,1625
|
|
9
|
+
database_wrapper_pgsql-0.3.146.dist-info/licenses/LICENSE,sha256=7P9Q3qmdxgm5mcSHNP7uQ1f0qH9voGXDwLWxjGjtVqM,1080
|
|
10
|
+
database_wrapper_pgsql-0.3.146.dist-info/METADATA,sha256=o8VbvzxlacLqzE8DmUye2OjCIttNQ0MgPkeVko1eLqQ,3143
|
|
11
|
+
database_wrapper_pgsql-0.3.146.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
12
|
+
database_wrapper_pgsql-0.3.146.dist-info/top_level.txt,sha256=EQhZLk12wRdsSp-Lo3Jc4cXmNfG8y5EouNv_7OBCSGo,23
|
|
13
|
+
database_wrapper_pgsql-0.3.146.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Gints Murāns
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
database_wrapper_pgsql/__init__.py,sha256=p1CkqOmXI61cy3uzpnRtukUG8vQrLfXCFPrwDfOEvFU,1161
|
|
2
|
-
database_wrapper_pgsql/connector.py,sha256=yY2Q95U8Jqty2L6eZ3pzQeWDExoP67Ejc7qFCPuKD84,27202
|
|
3
|
-
database_wrapper_pgsql/db_wrapper_pgsql.py,sha256=lrMN9lqfS0JapEfNu2sFeFxifK67eBhZZebU3MpvnRk,1909
|
|
4
|
-
database_wrapper_pgsql/db_wrapper_pgsql_async.py,sha256=cYYyBFWvVG3e24Ik0mJXnbxic9bskqnB-K3hEbJ6pk8,2025
|
|
5
|
-
database_wrapper_pgsql/db_wrapper_pgsql_mixin.py,sha256=_mLRkny8Outf3HaLcUCN7jDyZXMsaroK30U7c-6tbPs,5536
|
|
6
|
-
database_wrapper_pgsql/pg_introspector.py,sha256=-9_tTxOG7778gxaGuhsxcbCN42mEjr9kG-EAegxsU74,2684
|
|
7
|
-
database_wrapper_pgsql/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
database_wrapper_pgsql/type_mapping.py,sha256=KWIAT78Z6h5DEt8uQNfQP6t5ahBUPuLKgcPfQmIywM4,1625
|
|
9
|
-
database_wrapper_pgsql-0.2.36.dist-info/METADATA,sha256=MTP0ErpYJCHKw5jSjZAmW6HcP72q4Cymi3w22YP3JF8,3231
|
|
10
|
-
database_wrapper_pgsql-0.2.36.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
11
|
-
database_wrapper_pgsql-0.2.36.dist-info/top_level.txt,sha256=EQhZLk12wRdsSp-Lo3Jc4cXmNfG8y5EouNv_7OBCSGo,23
|
|
12
|
-
database_wrapper_pgsql-0.2.36.dist-info/RECORD,,
|
{database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.3.146.dist-info}/top_level.txt
RENAMED
|
File without changes
|