lesscode-database 0.0.8__tar.gz → 0.0.9__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.
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/PKG-INFO +1 -1
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/connect_pool.py +71 -6
- lesscode_database-0.0.9/lesscode_database/version.py +1 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database.egg-info/PKG-INFO +1 -1
- lesscode_database-0.0.8/lesscode_database/version.py +0 -1
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/LICENSE +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/README.md +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/__init__.py +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/connection_info.py +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/db_options.py +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/db_request.py +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/ds_helper.py +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/dynamic_import_package.py +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/mongo_base_model.py +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database.egg-info/SOURCES.txt +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database.egg-info/dependency_links.txt +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database.egg-info/top_level.txt +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/setup.cfg +0 -0
- {lesscode_database-0.0.8 → lesscode_database-0.0.9}/setup.py +0 -0
|
@@ -657,13 +657,22 @@ class Pool:
|
|
|
657
657
|
@staticmethod
|
|
658
658
|
def sync_create_clickhouse_pool(conn_info: ConnectionInfo):
|
|
659
659
|
try:
|
|
660
|
-
|
|
660
|
+
pooled_db = importlib.import_module("dbutils.pooled_db")
|
|
661
|
+
except ImportError:
|
|
662
|
+
raise Exception(f"DBUtils is not exist,run:pip install DBUtils==3.0.2")
|
|
663
|
+
try:
|
|
664
|
+
clickhouse_driver = importlib.import_module("clickhouse_driver")
|
|
661
665
|
except ImportError:
|
|
662
|
-
raise
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
666
|
+
raise Exception(f"clickhouse_driver is not exist,run:pip install clickhouse_driver")
|
|
667
|
+
params = conn_info.params
|
|
668
|
+
if not isinstance(params, dict):
|
|
669
|
+
params = dict()
|
|
670
|
+
|
|
671
|
+
pool = pooled_db.PooledDB(creator=clickhouse_driver.connect, host=conn_info.host, port=conn_info.port,
|
|
672
|
+
user=conn_info.user,
|
|
673
|
+
password=conn_info.password, database=conn_info.db_name or "default",
|
|
674
|
+
**params)
|
|
675
|
+
return pool
|
|
667
676
|
|
|
668
677
|
@staticmethod
|
|
669
678
|
def create_sqlalchemy_pool(conn_info: ConnectionInfo):
|
|
@@ -781,6 +790,56 @@ class Pool:
|
|
|
781
790
|
True) if conn_info.params else True)
|
|
782
791
|
return engine
|
|
783
792
|
|
|
793
|
+
@staticmethod
|
|
794
|
+
def sync_create_dbutils_pool(conn_info: ConnectionInfo):
|
|
795
|
+
params = conn_info.params
|
|
796
|
+
if not isinstance(params, dict):
|
|
797
|
+
params = dict()
|
|
798
|
+
creator = params.pop("creator")
|
|
799
|
+
try:
|
|
800
|
+
generic = importlib.import_module(creator)
|
|
801
|
+
except ImportError:
|
|
802
|
+
raise Exception(f"{creator} is not exist,run:pip install {creator}")
|
|
803
|
+
try:
|
|
804
|
+
pooled_db = importlib.import_module("dbutils.pooled_db")
|
|
805
|
+
steady_db = importlib.import_module("dbutils.steady_db")
|
|
806
|
+
simple_pooled_db = importlib.import_module("dbutils.simple_pooled_db")
|
|
807
|
+
persistent_db = importlib.import_module("dbutils.persistent_db")
|
|
808
|
+
except ImportError:
|
|
809
|
+
raise Exception(f"DBUtils is not exist,run:pip install DBUtils==3.0.2")
|
|
810
|
+
pool_type = params.pop("pool_type", "PooledDB")
|
|
811
|
+
if pool_type not in ["SimplePooledDB", "SteadyDBConnection", "PersistentDB", "PooledDB"]:
|
|
812
|
+
pool_type = "PooledDB"
|
|
813
|
+
|
|
814
|
+
mincached = params.pop("mincached", conn_info.min_size)
|
|
815
|
+
maxusage = params.pop("maxusage", conn_info.min_size)
|
|
816
|
+
maxshared = params.pop("maxshared", conn_info.max_size)
|
|
817
|
+
maxcached = params.pop("maxcached", conn_info.max_size)
|
|
818
|
+
blocking = params.pop("blocking", True)
|
|
819
|
+
reset = params.pop("reset", True)
|
|
820
|
+
setsession = params.pop("setsession", None)
|
|
821
|
+
failures = params.pop("failures", None)
|
|
822
|
+
ping = params.pop("ping", 1)
|
|
823
|
+
threadlocal = params.pop("threadlocal", None)
|
|
824
|
+
closeable = params.pop("closeable", True)
|
|
825
|
+
maxconnections = params.pop("maxconnections", None)
|
|
826
|
+
if pool_type == "SimplePooledDB":
|
|
827
|
+
pool = simple_pooled_db.PooledDB(dbapi=creator, maxconnections=maxconnections, **params)
|
|
828
|
+
elif pool_type == "SteadyDBConnection":
|
|
829
|
+
pool = steady_db.SteadyDBConnection(creator=creator, maxusage=maxusage, setsession=setsession,
|
|
830
|
+
failures=failures,
|
|
831
|
+
ping=ping, closeable=closeable, **params)
|
|
832
|
+
elif pool_type == "PersistentDB":
|
|
833
|
+
pool = persistent_db.PersistentDB(creator=creator, maxusage=maxusage, setsession=setsession,
|
|
834
|
+
failures=failures, ping=ping,
|
|
835
|
+
closeable=closeable, threadlocal=threadlocal, **params)
|
|
836
|
+
else:
|
|
837
|
+
pool = pooled_db.PooledDB(creator=generic, mincached=mincached, maxcached=maxcached,
|
|
838
|
+
maxshared=maxshared, maxconnections=conn_info.max_size, blocking=blocking,
|
|
839
|
+
maxusage=maxusage, setsession=setsession, reset=reset,
|
|
840
|
+
failures=failures, ping=ping, **params)
|
|
841
|
+
return pool
|
|
842
|
+
|
|
784
843
|
|
|
785
844
|
def run_sync(func_instance):
|
|
786
845
|
if iscoroutine(func_instance):
|
|
@@ -886,5 +945,11 @@ def get_pool(conn_info: ConnectionInfo):
|
|
|
886
945
|
else:
|
|
887
946
|
return run_sync(Pool.sync_create_sqlalchemy_pool(conn_info)), conn_info
|
|
888
947
|
|
|
948
|
+
elif conn_info.dialect == "dbutils":
|
|
949
|
+
if conn_info.async_enable:
|
|
950
|
+
return run_sync(Pool.sync_create_dbutils_pool(conn_info)), conn_info
|
|
951
|
+
else:
|
|
952
|
+
return run_sync(Pool.sync_create_dbutils_pool(conn_info)), conn_info
|
|
953
|
+
|
|
889
954
|
else:
|
|
890
955
|
raise Exception(f"conn_info.dialect={conn_info.dialect} is not supported")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.9"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.8"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database/dynamic_import_package.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{lesscode_database-0.0.8 → lesscode_database-0.0.9}/lesscode_database.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|