database-wrapper-pgsql 0.2.36__tar.gz → 0.3.146__tar.gz

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.
Files changed (18) hide show
  1. database_wrapper_pgsql-0.3.146/LICENSE +21 -0
  2. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/PKG-INFO +10 -9
  3. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql/__init__.py +1 -1
  4. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql/connector.py +32 -22
  5. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql/db_wrapper_pgsql_mixin.py +3 -2
  6. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql.egg-info/PKG-INFO +10 -9
  7. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql.egg-info/SOURCES.txt +1 -0
  8. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql.egg-info/requires.txt +1 -1
  9. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/pyproject.toml +12 -10
  10. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/README.md +0 -0
  11. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql/db_wrapper_pgsql.py +0 -0
  12. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql/db_wrapper_pgsql_async.py +0 -0
  13. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql/pg_introspector.py +0 -0
  14. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql/py.typed +0 -0
  15. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql/type_mapping.py +0 -0
  16. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql.egg-info/dependency_links.txt +0 -0
  17. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/database_wrapper_pgsql.egg-info/top_level.txt +0 -0
  18. {database_wrapper_pgsql-0.2.36 → database_wrapper_pgsql-0.3.146}/setup.cfg +0 -0
@@ -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,19 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: database_wrapper_pgsql
3
- Version: 0.2.36
3
+ Version: 0.3.146
4
4
  Summary: database_wrapper for PostgreSQL database
5
5
  Author-email: Gints Murans <gm@gm.lv>
6
- License: GNU General Public License v3.0 (GPL-3.0)
7
- Project-URL: Homepage, https://github.com/gintsmurans/py_database_wrapper
8
- Project-URL: Documentation, https://github.com/gintsmurans/py_database_wrapper
9
- Project-URL: Changes, https://github.com/gintsmurans/py_database_wrapper
10
- Project-URL: Code, https://github.com/gintsmurans/py_database_wrapper
11
- Project-URL: Issue Tracker, https://github.com/gintsmurans/py_database_wrapper/issues
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
- Requires-Dist: database_wrapper==0.2.36
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
 
@@ -4,7 +4,7 @@ database_wrapper_pgsql package - PostgreSQL database wrapper
4
4
  Part of the database_wrapper package
5
5
  """
6
6
 
7
- # Copyright 2024 Gints Murans
7
+ # Copyright 2024 Gints Murāns
8
8
 
9
9
  import logging
10
10
 
@@ -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
- reconnect_timeout=0,
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
- # Lets set the context var so that it is set even if we fail to get connection
520
- self.context_connection.set(None)
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
- test_data = self.context_connection.get()
536
- if test_data:
537
- self.return_connection(test_data[0])
538
-
539
- # Reset context
540
- self.context_connection.set(None)
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
- reconnect_timeout=0,
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
- # Lets set the context var so that it is set even if we fail to get connection
823
- self.context_connection_async.set(None)
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
- test_data = self.context_connection_async.get()
839
- if test_data:
840
- await self.return_connection(test_data[0])
841
-
842
- # Reset context
843
- self.context_connection_async.set(None)
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
- sql.Identifier(item[0]),
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
  )
@@ -1,19 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: database_wrapper_pgsql
3
- Version: 0.2.36
3
+ Version: 0.3.146
4
4
  Summary: database_wrapper for PostgreSQL database
5
5
  Author-email: Gints Murans <gm@gm.lv>
6
- License: GNU General Public License v3.0 (GPL-3.0)
7
- Project-URL: Homepage, https://github.com/gintsmurans/py_database_wrapper
8
- Project-URL: Documentation, https://github.com/gintsmurans/py_database_wrapper
9
- Project-URL: Changes, https://github.com/gintsmurans/py_database_wrapper
10
- Project-URL: Code, https://github.com/gintsmurans/py_database_wrapper
11
- Project-URL: Issue Tracker, https://github.com/gintsmurans/py_database_wrapper/issues
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
- Requires-Dist: database_wrapper==0.2.36
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
 
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  pyproject.toml
3
4
  database_wrapper_pgsql/__init__.py
@@ -1,3 +1,3 @@
1
- database_wrapper==0.2.36
1
+ database_wrapper==0.3.146
2
2
  psycopg[binary]>=3.2.0
3
3
  psycopg[pool]>=3.2.0
@@ -1,19 +1,21 @@
1
1
  [build-system]
2
- requires = ["setuptools >= 61.0.0"]
2
+ requires = ["setuptools >= 77.0.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "database_wrapper_pgsql"
7
- version = "0.2.36"
7
+ # Major.minor only; the patch is the git commit count, stamped at build time by
8
+ # scripts/set_version.bash. See scripts/version.bash for what the next release is.
9
+ version = "0.3.146"
8
10
  description = "database_wrapper for PostgreSQL database"
9
11
  readme = "README.md"
10
12
  requires-python = ">=3.8"
11
- license = { text = "GNU General Public License v3.0 (GPL-3.0)" }
13
+ license = "MIT"
14
+ license-files = ["LICENSE"]
12
15
  authors = [{ name = "Gints Murans", email = "gm@gm.lv" }]
13
16
  classifiers = [
14
17
  "Development Status :: 4 - Beta",
15
18
  "Intended Audience :: Developers",
16
- "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
17
19
  "Operating System :: MacOS :: MacOS X",
18
20
  "Operating System :: Microsoft :: Windows",
19
21
  "Operating System :: POSIX",
@@ -33,17 +35,17 @@ classifiers = [
33
35
  ]
34
36
  keywords = ["database", "wrapper", "python", "postgresql", "pgsql"]
35
37
  dependencies = [
36
- "database_wrapper == 0.2.36",
38
+ "database_wrapper == 0.3.146",
37
39
  "psycopg[binary] >= 3.2.0",
38
40
  "psycopg[pool] >= 3.2.0",
39
41
  ]
40
42
 
41
43
  [project.urls]
42
- Homepage = "https://github.com/gintsmurans/py_database_wrapper"
43
- Documentation = "https://github.com/gintsmurans/py_database_wrapper"
44
- Changes = "https://github.com/gintsmurans/py_database_wrapper"
45
- Code = "https://github.com/gintsmurans/py_database_wrapper"
46
- "Issue Tracker" = "https://github.com/gintsmurans/py_database_wrapper/issues"
44
+ Homepage = "https://github.com/4Apps/py_database_wrapper"
45
+ Documentation = "https://github.com/4Apps/py_database_wrapper"
46
+ Changes = "https://github.com/4Apps/py_database_wrapper"
47
+ Code = "https://github.com/4Apps/py_database_wrapper"
48
+ "Issue Tracker" = "https://github.com/4Apps/py_database_wrapper/issues"
47
49
  Download = "https://pypi.org/project/database_wrapper/"
48
50
 
49
51
  [tool.setuptools.package-data]