mtsql 1.11.3__py3-none-any.whl → 1.11.4__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 +50 -0
- mt/sql/version.py +1 -1
- {mtsql-1.11.3.dist-info → mtsql-1.11.4.dist-info}/METADATA +1 -1
- mtsql-1.11.4.dist-info/RECORD +12 -0
- {mtsql-1.11.3.dist-info → mtsql-1.11.4.dist-info}/WHEEL +1 -1
- mtsql-1.11.3.dist-info/RECORD +0 -12
- {mtsql-1.11.3.dist-info → mtsql-1.11.4.dist-info}/LICENSE +0 -0
- {mtsql-1.11.3.dist-info → mtsql-1.11.4.dist-info}/top_level.txt +0 -0
mt/sql/base.py
CHANGED
|
@@ -23,6 +23,9 @@ __all__ = [
|
|
|
23
23
|
"list_views",
|
|
24
24
|
"table_exists",
|
|
25
25
|
"create_temp_id_table",
|
|
26
|
+
"temp_table_name",
|
|
27
|
+
"temp_table_find_new_id",
|
|
28
|
+
"temp_table_drop",
|
|
26
29
|
]
|
|
27
30
|
|
|
28
31
|
|
|
@@ -387,3 +390,50 @@ def create_temp_id_table(l_ids: list, conn: sa.engine.Connection) -> str:
|
|
|
387
390
|
conn.execute(sa.text(query_str))
|
|
388
391
|
|
|
389
392
|
return table_name
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def temp_table_name(id: int) -> str:
|
|
396
|
+
"""Converts a temp table id into a temp table name."""
|
|
397
|
+
return f"mttmp_{id}"
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
def temp_table_find_new_id(engine: sa.engine.Engine) -> int:
|
|
401
|
+
"""Finds a new temp table id that does not exist in the public schema.
|
|
402
|
+
|
|
403
|
+
Parameters
|
|
404
|
+
----------
|
|
405
|
+
engine : sqlalchemy.engine.Engine
|
|
406
|
+
connection engine to the server
|
|
407
|
+
|
|
408
|
+
Returns
|
|
409
|
+
-------
|
|
410
|
+
id : int
|
|
411
|
+
table id that has not been existent in the public schema.
|
|
412
|
+
"""
|
|
413
|
+
l_tableNames = list_tables(engine)
|
|
414
|
+
max_id = -1
|
|
415
|
+
for table_name in l_tableNames:
|
|
416
|
+
s = re.match(r"mttmp_(\d+)", table_name)
|
|
417
|
+
if s:
|
|
418
|
+
id = int(s[1])
|
|
419
|
+
if max_id < id:
|
|
420
|
+
max_id = id
|
|
421
|
+
return max_id + 1
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def temp_table_drop(
|
|
425
|
+
id: int,
|
|
426
|
+
engine: sa.engine.Engine,
|
|
427
|
+
):
|
|
428
|
+
"""Drops a temp table.
|
|
429
|
+
|
|
430
|
+
Parameters
|
|
431
|
+
----------
|
|
432
|
+
id : int
|
|
433
|
+
table id. Can be generated by invoking :func:`temp_table_find_new_id`
|
|
434
|
+
engine : sqlalchemy.engine.Engine
|
|
435
|
+
connection engine to the server
|
|
436
|
+
"""
|
|
437
|
+
|
|
438
|
+
sql = f"DROP TABLE IF EXISTS {temp_table_name(id)}"
|
|
439
|
+
return engine_execute(engine, sql)
|
mt/sql/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mtsql
|
|
3
|
-
Version: 1.11.
|
|
3
|
+
Version: 1.11.4
|
|
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']
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
mt/sql/__init__.py,sha256=b7zO50apZxt9Hg2eOkJhRLrXgACR8eS5b-Rphdn5qNQ,44
|
|
2
|
+
mt/sql/base.py,sha256=H_bDZWgtaleNcb45atrgrk3fYwVw9OskrkZsfFWP5VA,11786
|
|
3
|
+
mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
|
|
4
|
+
mt/sql/psql.py,sha256=tzsIN2XyBJX8t7p0D2yXgEQwUTkTcDzllI4HunCfq3s,66345
|
|
5
|
+
mt/sql/redshift.py,sha256=Nve12tQ6_vO3M6yOpQQn3TkI1r4eDRBLsU0agOLRDvs,17037
|
|
6
|
+
mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
|
|
7
|
+
mt/sql/version.py,sha256=EJI7ks7VazIXVEXRmxPmjvpx4qjsXGHfiJ5XSOskhlI,207
|
|
8
|
+
mtsql-1.11.4.dist-info/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
|
|
9
|
+
mtsql-1.11.4.dist-info/METADATA,sha256=rxQ6i-8lbpMiFqPw7ZTASYmEhRDXj5ZQTQWoYvRyPo4,579
|
|
10
|
+
mtsql-1.11.4.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
11
|
+
mtsql-1.11.4.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
|
|
12
|
+
mtsql-1.11.4.dist-info/RECORD,,
|
mtsql-1.11.3.dist-info/RECORD
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
mt/sql/__init__.py,sha256=b7zO50apZxt9Hg2eOkJhRLrXgACR8eS5b-Rphdn5qNQ,44
|
|
2
|
-
mt/sql/base.py,sha256=iz60AAer-kSFNKotRP6D2JtxIwPyIyL8BJYVVLtmZco,10569
|
|
3
|
-
mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
|
|
4
|
-
mt/sql/psql.py,sha256=tzsIN2XyBJX8t7p0D2yXgEQwUTkTcDzllI4HunCfq3s,66345
|
|
5
|
-
mt/sql/redshift.py,sha256=Nve12tQ6_vO3M6yOpQQn3TkI1r4eDRBLsU0agOLRDvs,17037
|
|
6
|
-
mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
|
|
7
|
-
mt/sql/version.py,sha256=Qi5LGoO7TZ4qAVw4wY48Y93y0s5fIxvoXnq2OAVlJtk,207
|
|
8
|
-
mtsql-1.11.3.dist-info/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
|
|
9
|
-
mtsql-1.11.3.dist-info/METADATA,sha256=rc9T8lsrBi6DENup8tRb9l8b9C8AIKzbcHMR0te8zGw,579
|
|
10
|
-
mtsql-1.11.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
11
|
-
mtsql-1.11.3.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
|
|
12
|
-
mtsql-1.11.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|