lesscode-database 0.0.10__py3-none-any.whl → 0.0.11__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.
Potentially problematic release.
This version of lesscode-database might be problematic. Click here for more details.
- lesscode_database/connect_pool.py +53 -23
- lesscode_database/version.py +1 -1
- {lesscode_database-0.0.10.dist-info → lesscode_database-0.0.11.dist-info}/METADATA +1 -1
- {lesscode_database-0.0.10.dist-info → lesscode_database-0.0.11.dist-info}/RECORD +7 -7
- {lesscode_database-0.0.10.dist-info → lesscode_database-0.0.11.dist-info}/WHEEL +1 -1
- {lesscode_database-0.0.10.dist-info → lesscode_database-0.0.11.dist-info}/LICENSE +0 -0
- {lesscode_database-0.0.10.dist-info → lesscode_database-0.0.11.dist-info}/top_level.txt +0 -0
|
@@ -3,6 +3,7 @@ import asyncio
|
|
|
3
3
|
import importlib
|
|
4
4
|
import ssl
|
|
5
5
|
from inspect import iscoroutine
|
|
6
|
+
from xml.sax import parse
|
|
6
7
|
|
|
7
8
|
from lesscode_database.connection_info import ConnectionInfo
|
|
8
9
|
from lesscode_database.db_request import get_basic_auth
|
|
@@ -644,34 +645,63 @@ class Pool:
|
|
|
644
645
|
|
|
645
646
|
@staticmethod
|
|
646
647
|
async def create_clickhouse_pool(conn_info: ConnectionInfo):
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
648
|
+
|
|
649
|
+
params = conn_info.params if conn_info.params else {}
|
|
650
|
+
creator_type = params.pop("creator_type","asynch")
|
|
651
|
+
if creator_type == "clickhouse_connect":
|
|
652
|
+
try:
|
|
653
|
+
clickhouse_connect = importlib.import_module("clickhouse_connect")
|
|
654
|
+
except ImportError:
|
|
655
|
+
raise Exception(f"DBUtils is not exist,run:pip install clickhouse_connect==0.8.6")
|
|
656
|
+
pool = await clickhouse_connect.get_async_client(host=conn_info.host, port=conn_info.port,
|
|
657
|
+
username=conn_info.user,
|
|
658
|
+
password=conn_info.password, database=conn_info.db_name,
|
|
659
|
+
**params)
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
else:
|
|
663
|
+
try:
|
|
664
|
+
asynch = importlib.import_module("asynch")
|
|
665
|
+
except ImportError:
|
|
666
|
+
raise ImportError(f"asynch is not exist,run:pip install asynch")
|
|
667
|
+
pool = await asynch.create_pool(minsize=conn_info.min_size, maxsize=conn_info.max_size,
|
|
668
|
+
dsn=conn_info.dsn, host=conn_info.host,
|
|
669
|
+
user=conn_info.user, password=conn_info.password,
|
|
670
|
+
port=conn_info.port, database=conn_info.db_name)
|
|
655
671
|
return pool
|
|
656
672
|
|
|
657
673
|
@staticmethod
|
|
658
674
|
def sync_create_clickhouse_pool(conn_info: ConnectionInfo):
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
675
|
+
params = conn_info.params if conn_info.params else {}
|
|
676
|
+
creator_type = params.pop("creator_type", "clickhouse_driver")
|
|
677
|
+
if creator_type == "clickhouse_connect":
|
|
678
|
+
try:
|
|
679
|
+
clickhouse_connect = importlib.import_module("clickhouse_connect")
|
|
680
|
+
except ImportError:
|
|
681
|
+
raise Exception(f"DBUtils is not exist,run:pip install clickhouse_connect==0.6.23")
|
|
682
|
+
params = conn_info.params
|
|
683
|
+
if not params:
|
|
684
|
+
params = dict()
|
|
685
|
+
pool = clickhouse_connect.get_client(host=conn_info.host, port=conn_info.port, username=conn_info.user,
|
|
686
|
+
password=conn_info.password, database=conn_info.db_name, **params)
|
|
687
|
+
else:
|
|
688
|
+
try:
|
|
689
|
+
pooled_db = importlib.import_module("dbutils.pooled_db")
|
|
690
|
+
except ImportError:
|
|
691
|
+
raise Exception(f"DBUtils is not exist,run:pip install DBUtils==3.0.2")
|
|
692
|
+
try:
|
|
693
|
+
clickhouse_driver = importlib.import_module("clickhouse_driver")
|
|
694
|
+
except ImportError:
|
|
695
|
+
raise Exception(f"clickhouse_driver is not exist,run:pip install clickhouse_driver")
|
|
696
|
+
params = conn_info.params
|
|
697
|
+
if not isinstance(params, dict):
|
|
698
|
+
params = dict()
|
|
699
|
+
|
|
700
|
+
pool = pooled_db.PooledDB(creator=clickhouse_driver.connect, host=conn_info.host, port=conn_info.port,
|
|
701
|
+
user=conn_info.user,
|
|
702
|
+
password=conn_info.password, database=conn_info.db_name or "default",
|
|
703
|
+
**params)
|
|
670
704
|
|
|
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
705
|
return pool
|
|
676
706
|
|
|
677
707
|
@staticmethod
|
lesscode_database/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.0.
|
|
1
|
+
__version__ = "0.0.11"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
lesscode_database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
lesscode_database/connect_pool.py,sha256=
|
|
2
|
+
lesscode_database/connect_pool.py,sha256=9uNqtUX_flObmhKkwoXPsN_t2Lhs-0o4CdBmmo68yeY,48144
|
|
3
3
|
lesscode_database/connection_info.py,sha256=HMlA-hA0LE7jGUS8crZAgrBMB-o6B9mxrWYEywgqXHg,1307
|
|
4
4
|
lesscode_database/db_options.py,sha256=Z8Iy3pqDYW5YVVfvoFSsAYecK9LfiwRasYc3fzqIBt8,1928
|
|
5
5
|
lesscode_database/db_request.py,sha256=siZGXIdPuTlY4NwVLnU8098bVM_6jgQzSzeO4BzkDrA,4832
|
|
6
6
|
lesscode_database/ds_helper.py,sha256=W3VrTe_l0mGX0uEbN7UI6NlQbruLpr2WXgO7AexzQ-k,4845
|
|
7
7
|
lesscode_database/dynamic_import_package.py,sha256=J8hgGRHe6KrprOgOq-xbKHVAYHSjUBcNyTaSPvBmvIk,164
|
|
8
8
|
lesscode_database/mongo_base_model.py,sha256=cKHNmi5GJBGRxCtqsggEcrzIZK7__Z_4cVaIHxmqZsc,6406
|
|
9
|
-
lesscode_database/version.py,sha256
|
|
10
|
-
lesscode_database-0.0.
|
|
11
|
-
lesscode_database-0.0.
|
|
12
|
-
lesscode_database-0.0.
|
|
13
|
-
lesscode_database-0.0.
|
|
14
|
-
lesscode_database-0.0.
|
|
9
|
+
lesscode_database/version.py,sha256=OaIl7v-6zEWEY90Jlh6yoBjO3zWX1oX7RsvqrK3o1TU,23
|
|
10
|
+
lesscode_database-0.0.11.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
11
|
+
lesscode_database-0.0.11.dist-info/METADATA,sha256=fFsDq8ciMIstY3xm8IWg88DtF4iQbpAEF3tEWiTc0aI,12066
|
|
12
|
+
lesscode_database-0.0.11.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
13
|
+
lesscode_database-0.0.11.dist-info/top_level.txt,sha256=h6cg13be6kkDfNaX9nWeDcfducTb5bKG5iYRO2JPmAM,18
|
|
14
|
+
lesscode_database-0.0.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|