altcodepro-polydb-python 2.3.14__tar.gz → 2.3.15__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.
- {altcodepro_polydb_python-2.3.14/src/altcodepro_polydb_python.egg-info → altcodepro_polydb_python-2.3.15}/PKG-INFO +1 -1
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/pyproject.toml +1 -1
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15/src/altcodepro_polydb_python.egg-info}/PKG-INFO +1 -1
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/PostgreSQLAdapter.py +54 -5
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/LICENSE +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/MANIFEST.in +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/README.md +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/requirements-aws.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/requirements-azure.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/requirements-dev.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/requirements-gcp.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/requirements-generic.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/requirements.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/setup.cfg +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/setup.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/altcodepro_polydb_python.egg-info/SOURCES.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/altcodepro_polydb_python.egg-info/dependency_links.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/altcodepro_polydb_python.egg-info/requires.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/altcodepro_polydb_python.egg-info/top_level.txt +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/PolyDB.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/__init__.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/AzureBlobStorageAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/AzureFileStorageAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/AzureQueueAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/AzureTableStorageAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/BlockchainBlobAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/BlockchainFileAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/BlockchainKVAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/BlockchainQueueAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/DynamoDBAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/EFSAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/FirestoreAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/GCPFilestoreAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/GCPPubSubAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/GCPStorageAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/MongoDBAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/S3Adapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/S3CompatibleAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/SQSAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/VercelBlobAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/VercelFileAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/VercelKVAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/VercelQueueAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/__init__.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/advanced_query.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/AuditStorage.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/__init__.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/context.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/manager.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/models.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/base/NoSQLKVAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/base/ObjectStorageAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/base/QueueAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/base/SharedFilesAdapter.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/base/__init__.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/batch.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/cache.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/cloudDatabaseFactory.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/databaseFactory.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/decorators.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/errors.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/json_safe.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/models.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/monitoring.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/multitenancy.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/py.typed +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/query.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/registry.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/retry.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/schema.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/security.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/types.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/utils.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/validation.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_aws.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_azure.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_blockchain.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_cloud_factory.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_gcp.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_mongodb.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_multi_engine.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_postgresql.py +0 -0
- {altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_vercel.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: altcodepro-polydb-python
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.15
|
|
4
4
|
Summary: Production-ready multi-cloud database abstraction layer with connection pooling, retry logic, and thread safety
|
|
5
5
|
Author: AltCodePro
|
|
6
6
|
Project-URL: Homepage, https://github.com/altcodepro/polydb-python
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "altcodepro-polydb-python"
|
|
7
|
-
version = "2.3.
|
|
7
|
+
version = "2.3.15"
|
|
8
8
|
description = "Production-ready multi-cloud database abstraction layer with connection pooling, retry logic, and thread safety"
|
|
9
9
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: altcodepro-polydb-python
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.15
|
|
4
4
|
Summary: Production-ready multi-cloud database abstraction layer with connection pooling, retry logic, and thread safety
|
|
5
5
|
Author: AltCodePro
|
|
6
6
|
Project-URL: Homepage, https://github.com/altcodepro/polydb-python
|
|
@@ -32,25 +32,64 @@ class PostgreSQLAdapter:
|
|
|
32
32
|
self._lock = threading.Lock()
|
|
33
33
|
self._initialize_pool()
|
|
34
34
|
|
|
35
|
+
def _ping_connection(self, conn) -> bool:
|
|
36
|
+
"""Test if connection is still alive"""
|
|
37
|
+
try:
|
|
38
|
+
with conn.cursor() as cur:
|
|
39
|
+
cur.execute("SELECT 1")
|
|
40
|
+
return True
|
|
41
|
+
except Exception:
|
|
42
|
+
return False
|
|
43
|
+
|
|
35
44
|
def _initialize_pool(self):
|
|
36
45
|
try:
|
|
37
46
|
import psycopg2.pool
|
|
47
|
+
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
|
|
48
|
+
|
|
49
|
+
# Enhance connection string with better Azure settings
|
|
50
|
+
dsn = self.connection_string
|
|
51
|
+
if "postgresql://" in dsn:
|
|
52
|
+
parsed = urlparse(dsn)
|
|
53
|
+
query = parse_qs(parsed.query)
|
|
54
|
+
query.setdefault("connect_timeout", ["30"])
|
|
55
|
+
query.setdefault("keepalives", ["1"])
|
|
56
|
+
query.setdefault("keepalives_idle", ["30"])
|
|
57
|
+
query.setdefault("keepalives_interval", ["10"])
|
|
58
|
+
query.setdefault("keepalives_count", ["5"])
|
|
59
|
+
|
|
60
|
+
new_query = urlencode(query, doseq=True)
|
|
61
|
+
parsed = parsed._replace(query=new_query)
|
|
62
|
+
dsn = urlunparse(parsed)
|
|
38
63
|
|
|
39
64
|
with self._lock:
|
|
40
65
|
if not self._pool:
|
|
41
66
|
self._pool = psycopg2.pool.ThreadedConnectionPool(
|
|
42
|
-
minconn=int(os.getenv("POSTGRES_MIN_CONNECTIONS", "
|
|
43
|
-
maxconn=int(os.getenv("POSTGRES_MAX_CONNECTIONS", "
|
|
44
|
-
dsn=
|
|
67
|
+
minconn=int(os.getenv("POSTGRES_MIN_CONNECTIONS", "5")),
|
|
68
|
+
maxconn=int(os.getenv("POSTGRES_MAX_CONNECTIONS", "30")),
|
|
69
|
+
dsn=dsn,
|
|
45
70
|
)
|
|
46
|
-
self.logger.info("PostgreSQL pool initialized")
|
|
71
|
+
self.logger.info("PostgreSQL pool initialized with Azure optimizations")
|
|
47
72
|
except Exception as e:
|
|
48
73
|
raise ConnectionError(f"Failed to initialize PostgreSQL pool: {str(e)}")
|
|
49
74
|
|
|
50
75
|
def _get_connection(self) -> Any:
|
|
51
76
|
if not self._pool:
|
|
52
77
|
self._initialize_pool()
|
|
53
|
-
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
conn = self._pool.getconn() # type: ignore
|
|
81
|
+
|
|
82
|
+
# Critical: Validate connection for Azure transient issues
|
|
83
|
+
if not self._ping_connection(conn):
|
|
84
|
+
self.logger.warning("Stale connection detected from pool, closing and retrying")
|
|
85
|
+
self._pool.putconn(conn, close=True) # type: ignore
|
|
86
|
+
conn = self._pool.getconn() # type: ignore # Get fresh connection
|
|
87
|
+
|
|
88
|
+
return conn
|
|
89
|
+
|
|
90
|
+
except Exception as e:
|
|
91
|
+
self.logger.error(f"Failed to acquire connection from pool: {e}")
|
|
92
|
+
raise ConnectionError(f"Could not obtain database connection: {e}") from e
|
|
54
93
|
|
|
55
94
|
def _return_connection(self, conn: Any):
|
|
56
95
|
if self._pool and conn:
|
|
@@ -59,6 +98,16 @@ class PostgreSQLAdapter:
|
|
|
59
98
|
# ---------------------------------------------------------------------
|
|
60
99
|
# TRANSACTIONS
|
|
61
100
|
# ---------------------------------------------------------------------
|
|
101
|
+
def reset_pool(self):
|
|
102
|
+
"""Reset the entire pool (call during startup or after major failures)"""
|
|
103
|
+
with self._lock:
|
|
104
|
+
if self._pool:
|
|
105
|
+
try:
|
|
106
|
+
self._pool.closeall()
|
|
107
|
+
except:
|
|
108
|
+
pass
|
|
109
|
+
self._pool = None
|
|
110
|
+
self._initialize_pool()
|
|
62
111
|
|
|
63
112
|
def begin_transaction(self) -> Any:
|
|
64
113
|
"""Begin a transaction and return the connection handle."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/requirements-generic.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/S3Adapter.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/adapters/__init__.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/advanced_query.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/AuditStorage.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/__init__.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/context.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/manager.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/audit/models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/base/QueueAdapter.py
RENAMED
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/base/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/databaseFactory.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/decorators.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/monitoring.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/multitenancy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/src/polydb/validation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_blockchain.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_cloud_factory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_multi_engine.py
RENAMED
|
File without changes
|
{altcodepro_polydb_python-2.3.14 → altcodepro_polydb_python-2.3.15}/tests/test_postgresql.py
RENAMED
|
File without changes
|
|
File without changes
|