mtsql 1.12.20__py3-none-any.whl → 1.12.22__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.
- mt/sql/base.py +10 -3
- mt/sql/version.py +1 -1
- {mtsql-1.12.20.dist-info → mtsql-1.12.22.dist-info}/METADATA +1 -1
- {mtsql-1.12.20.dist-info → mtsql-1.12.22.dist-info}/RECORD +7 -7
- {mtsql-1.12.20.dist-info → mtsql-1.12.22.dist-info}/WHEEL +0 -0
- {mtsql-1.12.20.dist-info → mtsql-1.12.22.dist-info}/licenses/LICENSE +0 -0
- {mtsql-1.12.20.dist-info → mtsql-1.12.22.dist-info}/top_level.txt +0 -0
mt/sql/base.py
CHANGED
|
@@ -76,6 +76,7 @@ def run_func(
|
|
|
76
76
|
se.InterfaceError,
|
|
77
77
|
se.PendingRollbackError,
|
|
78
78
|
ssl.SSLEOFError,
|
|
79
|
+
ssl.SSLZeroReturnError,
|
|
79
80
|
):
|
|
80
81
|
if x < nb_trials - 1:
|
|
81
82
|
if logger:
|
|
@@ -370,6 +371,7 @@ def create_temp_id_table(
|
|
|
370
371
|
conn: sa.engine.Connection,
|
|
371
372
|
int_type="int",
|
|
372
373
|
chunksize: int = 1000000,
|
|
374
|
+
logger: tp.Optional[logg.IndentedLoggerAdapter] = None,
|
|
373
375
|
) -> str:
|
|
374
376
|
"""Creates a temporary table to containing a list of ids.
|
|
375
377
|
|
|
@@ -383,6 +385,8 @@ def create_temp_id_table(
|
|
|
383
385
|
an SQL string representing the int type
|
|
384
386
|
chunksize : int
|
|
385
387
|
maximum number of ids to be inserted in each INSERT statement
|
|
388
|
+
logger : mt.logg.IndentedLoggerAdapter, optional
|
|
389
|
+
logger for debugging
|
|
386
390
|
|
|
387
391
|
Returns
|
|
388
392
|
-------
|
|
@@ -393,7 +397,7 @@ def create_temp_id_table(
|
|
|
393
397
|
table_name = f"tab_{uuid.uuid4().hex}"
|
|
394
398
|
|
|
395
399
|
query_str = f"CREATE TEMP TABLE {table_name}(id {int_type});"
|
|
396
|
-
exec_sql(sa.text(query_str), conn)
|
|
400
|
+
exec_sql(sa.text(query_str), conn, logger=logger)
|
|
397
401
|
|
|
398
402
|
while True:
|
|
399
403
|
l_ids2 = l_ids[:chunksize]
|
|
@@ -402,7 +406,7 @@ def create_temp_id_table(
|
|
|
402
406
|
|
|
403
407
|
values = ",".join((f"({id})" for id in l_ids2))
|
|
404
408
|
query_str = f"INSERT INTO {table_name}(id) VALUES {values};"
|
|
405
|
-
exec_sql(sa.text(query_str), conn)
|
|
409
|
+
exec_sql(sa.text(query_str), conn, logger=logger)
|
|
406
410
|
l_ids = l_ids[chunksize:]
|
|
407
411
|
|
|
408
412
|
return table_name
|
|
@@ -440,6 +444,7 @@ def temp_table_find_new_id(engine: sa.engine.Engine) -> int:
|
|
|
440
444
|
def temp_table_drop(
|
|
441
445
|
engine: sa.engine.Engine,
|
|
442
446
|
id: int,
|
|
447
|
+
logger: tp.Optional[logg.IndentedLoggerAdapter] = None,
|
|
443
448
|
):
|
|
444
449
|
"""Drops a temp table.
|
|
445
450
|
|
|
@@ -449,11 +454,13 @@ def temp_table_drop(
|
|
|
449
454
|
table id or table name. An id can be generated by invoking :func:`temp_table_find_new_id`.
|
|
450
455
|
engine : sqlalchemy.engine.Engine
|
|
451
456
|
connection engine to the server
|
|
457
|
+
logger : mt.logg.IndentedLoggerAdapter, optional
|
|
458
|
+
logger for debugging
|
|
452
459
|
"""
|
|
453
460
|
|
|
454
461
|
name = id if isinstance(id, str) else temp_table_name(id)
|
|
455
462
|
sql = f"DROP TABLE IF EXISTS {name}"
|
|
456
|
-
return exec_sql(sql, engine)
|
|
463
|
+
return exec_sql(sql, engine, logger=logger)
|
|
457
464
|
|
|
458
465
|
|
|
459
466
|
@ctx.contextmanager
|
mt/sql/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mtsql
|
|
3
|
-
Version: 1.12.
|
|
3
|
+
Version: 1.12.22
|
|
4
4
|
Summary: Extra Python modules to deal with the interaction between pandas dataframes and remote SQL servers, for Minh-Tri Pham
|
|
5
5
|
Home-page: https://github.com/inteplus/mtsql
|
|
6
6
|
Author: ['Minh-Tri Pham']
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
mt/sql/__init__.py,sha256=b7zO50apZxt9Hg2eOkJhRLrXgACR8eS5b-Rphdn5qNQ,44
|
|
2
|
-
mt/sql/base.py,sha256=
|
|
2
|
+
mt/sql/base.py,sha256=j2fzeGUdh-TnvgotuWOmTM-A0pqBg31z2c19bH5E_xk,13504
|
|
3
3
|
mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
|
|
4
4
|
mt/sql/psql.py,sha256=w5klr_2lUZnAFee-Fzbn3G8jdYcf_iX4N_GfAGIdsMI,66670
|
|
5
5
|
mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
|
|
6
|
-
mt/sql/version.py,sha256=
|
|
6
|
+
mt/sql/version.py,sha256=TMep9gRjrVIi_raEj5ssyAJSqu8WjBqWN-k1B6KZSgg,208
|
|
7
7
|
mt/sql/redshift/__init__.py,sha256=S-eRxJWcrvncF7LZXuulCdPV-UERu9eiw6uyDb5aGsM,443
|
|
8
8
|
mt/sql/redshift/commands.py,sha256=xhGUBf3bL66EYdZI5HCUtOx-XqPCnXT_P-LnhPgtzrY,40193
|
|
9
9
|
mt/sql/redshift/ddl.py,sha256=eUcZj9oIajiE1wKKBAP-V64gYJ7cVnSAt8dLFfluOJA,9777
|
|
10
10
|
mt/sql/redshift/dialect.py,sha256=-0JjJubZZHRw0abhl6H6rKWaUE9pKtGwAuX-62T0e_c,53399
|
|
11
11
|
mt/sql/redshift/main.py,sha256=H8_5sjtJ7dzWoCMXzPNjYhrMQ18eLUQ9xg-aYl5QeTc,17104
|
|
12
12
|
mt/sql/redshift/redshift-ca-bundle.crt,sha256=532qYkOpQOstFE0mdXE1GVtL3v00XDKgZNTr6gK5-KE,8621
|
|
13
|
-
mtsql-1.12.
|
|
14
|
-
mtsql-1.12.
|
|
15
|
-
mtsql-1.12.
|
|
16
|
-
mtsql-1.12.
|
|
17
|
-
mtsql-1.12.
|
|
13
|
+
mtsql-1.12.22.dist-info/licenses/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
|
|
14
|
+
mtsql-1.12.22.dist-info/METADATA,sha256=3zityjnam0Lf_ihhR1UDvNhJJ6bxqOlM8QPA0flFU78,740
|
|
15
|
+
mtsql-1.12.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
mtsql-1.12.22.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
|
|
17
|
+
mtsql-1.12.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|