database-wrapper-pgsql 0.2.36__py3-none-any.whl → 0.2.38__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/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.2.38.dist-info}/METADATA +2 -2
- {database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.2.38.dist-info}/RECORD +6 -6
- {database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.2.38.dist-info}/WHEEL +1 -1
- {database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.2.38.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.2.38.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper_pgsql
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.38
|
|
4
4
|
Summary: database_wrapper for PostgreSQL database
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -32,7 +32,7 @@ Classifier: Topic :: Software Development
|
|
|
32
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
|
-
Requires-Dist: database_wrapper==0.2.
|
|
35
|
+
Requires-Dist: database_wrapper==0.2.38
|
|
36
36
|
Requires-Dist: psycopg[binary]>=3.2.0
|
|
37
37
|
Requires-Dist: psycopg[pool]>=3.2.0
|
|
38
38
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
database_wrapper_pgsql/__init__.py,sha256=p1CkqOmXI61cy3uzpnRtukUG8vQrLfXCFPrwDfOEvFU,1161
|
|
2
|
-
database_wrapper_pgsql/connector.py,sha256=
|
|
2
|
+
database_wrapper_pgsql/connector.py,sha256=Dr_S0aD1SjfsTuCma1zQocSJSwWKOoePuR0fcEGM8r4,27993
|
|
3
3
|
database_wrapper_pgsql/db_wrapper_pgsql.py,sha256=lrMN9lqfS0JapEfNu2sFeFxifK67eBhZZebU3MpvnRk,1909
|
|
4
4
|
database_wrapper_pgsql/db_wrapper_pgsql_async.py,sha256=cYYyBFWvVG3e24Ik0mJXnbxic9bskqnB-K3hEbJ6pk8,2025
|
|
5
|
-
database_wrapper_pgsql/db_wrapper_pgsql_mixin.py,sha256=
|
|
5
|
+
database_wrapper_pgsql/db_wrapper_pgsql_mixin.py,sha256=pFAG6dX1_fjuDDKk0XSBxmBKwg6_w3KFbmf8M2JRxm4,5692
|
|
6
6
|
database_wrapper_pgsql/pg_introspector.py,sha256=-9_tTxOG7778gxaGuhsxcbCN42mEjr9kG-EAegxsU74,2684
|
|
7
7
|
database_wrapper_pgsql/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
database_wrapper_pgsql/type_mapping.py,sha256=KWIAT78Z6h5DEt8uQNfQP6t5ahBUPuLKgcPfQmIywM4,1625
|
|
9
|
-
database_wrapper_pgsql-0.2.
|
|
10
|
-
database_wrapper_pgsql-0.2.
|
|
11
|
-
database_wrapper_pgsql-0.2.
|
|
12
|
-
database_wrapper_pgsql-0.2.
|
|
9
|
+
database_wrapper_pgsql-0.2.38.dist-info/METADATA,sha256=muIPhFaxfYn0z9kUsINM6tq4OoVGFdBLOehJgeZTawI,3231
|
|
10
|
+
database_wrapper_pgsql-0.2.38.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
11
|
+
database_wrapper_pgsql-0.2.38.dist-info/top_level.txt,sha256=EQhZLk12wRdsSp-Lo3Jc4cXmNfG8y5EouNv_7OBCSGo,23
|
|
12
|
+
database_wrapper_pgsql-0.2.38.dist-info/RECORD,,
|
{database_wrapper_pgsql-0.2.36.dist-info → database_wrapper_pgsql-0.2.38.dist-info}/top_level.txt
RENAMED
|
File without changes
|