altcodepro-polydb-python 2.3.24__py3-none-any.whl → 2.3.26__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.
- {altcodepro_polydb_python-2.3.24.dist-info → altcodepro_polydb_python-2.3.26.dist-info}/METADATA +1 -1
- {altcodepro_polydb_python-2.3.24.dist-info → altcodepro_polydb_python-2.3.26.dist-info}/RECORD +9 -9
- {altcodepro_polydb_python-2.3.24.dist-info → altcodepro_polydb_python-2.3.26.dist-info}/WHEEL +1 -1
- polydb/__init__.py +3 -1
- polydb/adapters/AzureTableStorageAdapter.py +16 -1
- polydb/models.py +35 -0
- polydb/utils.py +39 -6
- {altcodepro_polydb_python-2.3.24.dist-info → altcodepro_polydb_python-2.3.26.dist-info}/licenses/LICENSE +0 -0
- {altcodepro_polydb_python-2.3.24.dist-info → altcodepro_polydb_python-2.3.26.dist-info}/top_level.txt +0 -0
{altcodepro_polydb_python-2.3.24.dist-info → altcodepro_polydb_python-2.3.26.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: altcodepro-polydb-python
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.26
|
|
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
|
{altcodepro_polydb_python-2.3.24.dist-info → altcodepro_polydb_python-2.3.26.dist-info}/RECORD
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
altcodepro_polydb_python-2.3.
|
|
1
|
+
altcodepro_polydb_python-2.3.26.dist-info/licenses/LICENSE,sha256=9X8GLocsBwy-5aR5JGOt2SAMDDPs9Qv-YnqmHBHOXrw,1067
|
|
2
2
|
polydb/PolyDB.py,sha256=MG7-nV59zDvrUQwXNEgV4eetHCeW9TYY9DQqtxu_r7k,23543
|
|
3
|
-
polydb/__init__.py,sha256=
|
|
3
|
+
polydb/__init__.py,sha256=d9KSz888A336904TPEjWPYBtyJLPB0lTdcaOnYp8byY,1535
|
|
4
4
|
polydb/advanced_query.py,sha256=cxMB-EB-qT3bWXJlhmjnMCUtrzogORWyoEfS50Dy7go,4280
|
|
5
5
|
polydb/batch.py,sha256=_DjWZa1ZXYSk6MLKqFe0eT7SYVRZtYNqZb9bI8Y2sao,4566
|
|
6
6
|
polydb/cache.py,sha256=JBXF1XEK-fY80ar8SDE893Z1Z116YtXAEG0PaJ0Nkcw,7658
|
|
@@ -9,7 +9,7 @@ polydb/databaseFactory.py,sha256=uBzX7K-k_aFHLQyFemy3XIe3lsOjAvjRFfaC6phITlA,414
|
|
|
9
9
|
polydb/decorators.py,sha256=L_WP2uXP_k8Ac49SUm-mthbM4jWI-XYfHXEyKzumOww,43062
|
|
10
10
|
polydb/errors.py,sha256=jF_55fbfg6b6mBc116dzU_uBG9qiIKbr5jvmDuJx-Jw,1573
|
|
11
11
|
polydb/json_safe.py,sha256=R5PrqAGirqjYKPyy-8KH-lSXjLH0FPr2TSGozy4eheU,149
|
|
12
|
-
polydb/models.py,sha256=
|
|
12
|
+
polydb/models.py,sha256=pkGpYnEEJmXdoWVpWS2K3CnuO9JZ_91DKp1bpVNQCns,10259
|
|
13
13
|
polydb/monitoring.py,sha256=UMm3ybyRJjAQi-prXXMLl9zuHhnhMnYBzMD3XWK66y8,9571
|
|
14
14
|
polydb/multitenancy.py,sha256=9kyY98RpKg8xDy9ejB_MyV_YzF7eZd4uxashw5S8vlg,6408
|
|
15
15
|
polydb/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -19,12 +19,12 @@ polydb/retry.py,sha256=OfmNglrmL6AQlJPmXNdy9A9lRkH0P-vZ5BUuMiUM__4,3795
|
|
|
19
19
|
polydb/schema.py,sha256=VrOayX6V6AD2Qh3-lm4ZVPTpI24e4V52IYheZf2rNQ4,5812
|
|
20
20
|
polydb/security.py,sha256=9ju-hc6Y1sxobCoV_mZ3ZWroUD73LodyTLVMhY_HeKU,16360
|
|
21
21
|
polydb/types.py,sha256=XB_85Un8_aWt4dSfpjIGotHbK3KBY2WurQGXr9EOxWY,2992
|
|
22
|
-
polydb/utils.py,sha256=
|
|
22
|
+
polydb/utils.py,sha256=tS_KI1vt-VZ6JftbFxbnVxC0xpie1-zYikTGf1nSoFw,3183
|
|
23
23
|
polydb/validation.py,sha256=a1o1d02k3c6PWQwkBbw_0nEmIgrdB5RR8OcpNQMn4cA,4810
|
|
24
24
|
polydb/adapters/AzureBlobStorageAdapter.py,sha256=4vD55Z8DBTzBK66jIJbo5bNMY-AQ61MlP0-P2Fv_JgQ,7083
|
|
25
25
|
polydb/adapters/AzureFileStorageAdapter.py,sha256=VZNprqlBXCuWUgtqClNT-NrQmRf-XFYEiRA2BLbf-Sc,7046
|
|
26
26
|
polydb/adapters/AzureQueueAdapter.py,sha256=5PrKAX4OQxUD5nReZKrInF_mjQVdFcj2aYd0Xp-HjjQ,5254
|
|
27
|
-
polydb/adapters/AzureTableStorageAdapter.py,sha256=
|
|
27
|
+
polydb/adapters/AzureTableStorageAdapter.py,sha256=CTi8qCVQDujqBGIfLJu2fgA2sNkDt07zrNIdyuQIcl4,27053
|
|
28
28
|
polydb/adapters/BlockchainBlobAdapter.py,sha256=D01Yua9mkKfaQrxKYApblIyI6DSP0dtNAh4Tav51HJ4,3299
|
|
29
29
|
polydb/adapters/BlockchainFileAdapter.py,sha256=G749xOVpG20HuKS8zCgi6PMjoJNu-YXK7zitygjLdzM,8335
|
|
30
30
|
polydb/adapters/BlockchainKVAdapter.py,sha256=UFYHyTgvdW-sZUBqyHEG3Cdx6wSTiF2QowEVWL3XPTg,4564
|
|
@@ -60,7 +60,7 @@ polydb/observability/logging.py,sha256=gv1SshNjaSkmR98Uv7Qbwq3gkeQUzVCA4ichqHKL6
|
|
|
60
60
|
polydb/services/__init__.py,sha256=nMolMXzmhejRSm7f42kU9fCHF0GIpqpejN2kywuBsUQ,241
|
|
61
61
|
polydb/services/compliance_service.py,sha256=-0ncX7PrXy4-NuyWXIv65cLUsqz0jXzb3LtsD8rlrXE,4983
|
|
62
62
|
polydb/services/security_service.py,sha256=q7GzK6sbMnBBsc4fuL4oXTd-ui2b-MYQyrWTBvdVNSk,5062
|
|
63
|
-
altcodepro_polydb_python-2.3.
|
|
64
|
-
altcodepro_polydb_python-2.3.
|
|
65
|
-
altcodepro_polydb_python-2.3.
|
|
66
|
-
altcodepro_polydb_python-2.3.
|
|
63
|
+
altcodepro_polydb_python-2.3.26.dist-info/METADATA,sha256=D5suhSTtKr4f65k7_le2erc4HEM1xXvAF0eh7wn8FFY,12359
|
|
64
|
+
altcodepro_polydb_python-2.3.26.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
65
|
+
altcodepro_polydb_python-2.3.26.dist-info/top_level.txt,sha256=WgLFWJoYjUhwvyPxJFl6jYLrVFuBJDX3OABf4ocwk_E,7
|
|
66
|
+
altcodepro_polydb_python-2.3.26.dist-info/RECORD,,
|
polydb/__init__.py
CHANGED
|
@@ -8,7 +8,7 @@ __version__ = "2.2.3"
|
|
|
8
8
|
|
|
9
9
|
from .cloudDatabaseFactory import CloudDatabaseFactory
|
|
10
10
|
from .databaseFactory import DatabaseFactory
|
|
11
|
-
from .models import CloudProvider, PartitionConfig
|
|
11
|
+
from .models import CloudProvider, PartitionConfig, MongoConfig, CosmosMongoConfig
|
|
12
12
|
from .query import QueryBuilder, Operator
|
|
13
13
|
from .audit.context import AuditContext
|
|
14
14
|
from .cache import RedisCacheEngine as CacheEngine
|
|
@@ -36,6 +36,8 @@ __all__ = [
|
|
|
36
36
|
# Models & Config
|
|
37
37
|
"CloudProvider",
|
|
38
38
|
"PartitionConfig",
|
|
39
|
+
"MongoConfig",
|
|
40
|
+
"CosmosMongoConfig",
|
|
39
41
|
# Query
|
|
40
42
|
"QueryBuilder",
|
|
41
43
|
"Operator",
|
|
@@ -567,7 +567,18 @@ class AzureTableStorageAdapter(NoSQLKVAdapter):
|
|
|
567
567
|
sval = str(ev).replace("'", "''")
|
|
568
568
|
parts.append(f"{sk} eq '{sval}'")
|
|
569
569
|
|
|
570
|
-
|
|
570
|
+
# Empty-filter contract: if the caller passed filter keys but every
|
|
571
|
+
# condition dropped out (e.g. all values None/unresolvable), the query
|
|
572
|
+
# must match NOTHING — return [] (→ None for a single-object read).
|
|
573
|
+
# Returning all entities here (query_filter=None) is how an unmatched
|
|
574
|
+
# read_one accidentally returned a stray context row. Only a genuinely
|
|
575
|
+
# empty filter dict means "list all".
|
|
576
|
+
if not parts:
|
|
577
|
+
if eff_filters:
|
|
578
|
+
return []
|
|
579
|
+
query_filter = None
|
|
580
|
+
else:
|
|
581
|
+
query_filter = " and ".join(parts)
|
|
571
582
|
|
|
572
583
|
entities = table_client.query_entities(query_filter=query_filter)
|
|
573
584
|
|
|
@@ -670,6 +681,10 @@ class AzureTableStorageAdapter(NoSQLKVAdapter):
|
|
|
670
681
|
else:
|
|
671
682
|
sval = str(ev).replace("'", "''")
|
|
672
683
|
parts.append(f"{sk} eq '{sval}'")
|
|
684
|
+
# Same empty-filter contract as _query_raw: filter keys that all resolved
|
|
685
|
+
# to no condition must match NOTHING, not list the whole table.
|
|
686
|
+
if not parts and eff_filters:
|
|
687
|
+
return PageResult(items=[], next_cursor=None, has_more=False)
|
|
673
688
|
query_filter = " and ".join(parts) if parts else None
|
|
674
689
|
|
|
675
690
|
azure_ct = None
|
polydb/models.py
CHANGED
|
@@ -323,3 +323,38 @@ class MongoConfig(StorageConfig):
|
|
|
323
323
|
super().__init__(CloudProvider.MONGODB, name)
|
|
324
324
|
self.mongo_uri = mongo_uri
|
|
325
325
|
self.db_name = db_name
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
class CosmosMongoConfig(MongoConfig):
|
|
329
|
+
"""Azure Cosmos DB via the **MongoDB API**.
|
|
330
|
+
|
|
331
|
+
Cosmos-for-Mongo speaks the MongoDB wire protocol, so it needs no adapter of
|
|
332
|
+
its own — it rides the existing ``MongoDBAdapter`` (and thus the whole polydb
|
|
333
|
+
stack) unchanged. This gives the best of both: Azure-native, serverless /
|
|
334
|
+
autoscale, managed billing + monitoring **and** portability — the same app
|
|
335
|
+
runs on MongoDB Atlas by swapping the connection string.
|
|
336
|
+
|
|
337
|
+
Pass a full ``connection_string`` (recommended — works for both RU and vCore),
|
|
338
|
+
or ``account`` + ``key`` to build the standard Cosmos-for-Mongo (RU) URI.
|
|
339
|
+
"""
|
|
340
|
+
|
|
341
|
+
def __init__(
|
|
342
|
+
self,
|
|
343
|
+
name: str = "cosmos",
|
|
344
|
+
*,
|
|
345
|
+
connection_string: str = "",
|
|
346
|
+
account: str = "",
|
|
347
|
+
key: str = "",
|
|
348
|
+
db_name: str = "",
|
|
349
|
+
port: int = 10255,
|
|
350
|
+
):
|
|
351
|
+
uri = connection_string
|
|
352
|
+
if not uri and account and key:
|
|
353
|
+
uri = (
|
|
354
|
+
f"mongodb://{account}:{key}@{account}.mongo.cosmos.azure.com:{port}/"
|
|
355
|
+
f"?ssl=true&replicaSet=globaldb&retrywrites=false"
|
|
356
|
+
f"&maxIdleTimeMS=120000&appName=@{account}@"
|
|
357
|
+
)
|
|
358
|
+
super().__init__(name=name, mongo_uri=uri, db_name=db_name)
|
|
359
|
+
self.is_cosmos = True
|
|
360
|
+
self.account = account
|
polydb/utils.py
CHANGED
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
Utility functions for validation and logging
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
+
import os
|
|
6
7
|
import re
|
|
7
8
|
import logging
|
|
8
9
|
from typing import Dict, Any
|
|
9
10
|
from .errors import ValidationError
|
|
10
11
|
|
|
12
|
+
# Loggers already configured by setup_logger(), so per-request adapter
|
|
13
|
+
# construction doesn't reconfigure (and re-clobber) them repeatedly.
|
|
14
|
+
_configured_loggers: set[str] = set()
|
|
15
|
+
|
|
11
16
|
|
|
12
17
|
def validate_table_name(table: str) -> str:
|
|
13
18
|
"""
|
|
@@ -43,19 +48,47 @@ def validate_columns(data: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
43
48
|
|
|
44
49
|
|
|
45
50
|
def setup_logger(name: str, level: int = logging.INFO) -> logging.Logger:
|
|
46
|
-
"""
|
|
51
|
+
"""Return a logger, configuring it at most once.
|
|
52
|
+
|
|
53
|
+
Adapters are constructed per request, so running the full setup on every
|
|
54
|
+
call would (a) reset a level the embedding app deliberately set and (b)
|
|
55
|
+
re-attach a duplicate plain-text handler — which is why "Initialized Azure
|
|
56
|
+
Queue Storage client" spammed on every request in both plain and JSON form.
|
|
57
|
+
|
|
58
|
+
Behaviour:
|
|
59
|
+
* Idempotent — a given logger name is configured only once.
|
|
60
|
+
* Host-managed root — when the embedding app owns root logging (it sets the
|
|
61
|
+
``ALTCODEPRO_ROOT_LOGGING_MANAGED`` sentinel), polydb attaches NO handler
|
|
62
|
+
of its own and does NOT force a level. Records propagate to the host's
|
|
63
|
+
formatter and honour whatever level the host pinned (so the host can
|
|
64
|
+
quiet noisy adapters). This is the standard "library shouldn't seize
|
|
65
|
+
logging" contract.
|
|
66
|
+
* Standalone — with no host managing root, keep the original behaviour:
|
|
67
|
+
set the level and install a plain StreamHandler.
|
|
68
|
+
"""
|
|
47
69
|
logger = logging.getLogger(name)
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
if name in _configured_loggers:
|
|
71
|
+
return logger
|
|
72
|
+
_configured_loggers.add(name)
|
|
73
|
+
|
|
74
|
+
host_managed = bool(os.getenv("ALTCODEPRO_ROOT_LOGGING_MANAGED"))
|
|
75
|
+
if host_managed:
|
|
76
|
+
# Let the host own formatting and level; just propagate.
|
|
77
|
+
return logger
|
|
78
|
+
|
|
79
|
+
# Respect a level the caller already pinned explicitly on this logger.
|
|
80
|
+
if logger.level == logging.NOTSET:
|
|
81
|
+
logger.setLevel(level)
|
|
82
|
+
|
|
50
83
|
# Clear existing handlers to avoid duplication in multiprocess scenarios
|
|
51
|
-
if logger.
|
|
84
|
+
if logger.handlers:
|
|
52
85
|
logger.handlers.clear()
|
|
53
|
-
|
|
86
|
+
|
|
54
87
|
handler = logging.StreamHandler()
|
|
55
88
|
formatter = logging.Formatter(
|
|
56
89
|
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
57
90
|
)
|
|
58
91
|
handler.setFormatter(formatter)
|
|
59
92
|
logger.addHandler(handler)
|
|
60
|
-
|
|
93
|
+
|
|
61
94
|
return logger
|
|
File without changes
|
|
File without changes
|