mtsql 1.12.2__py3-none-any.whl → 1.12.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 CHANGED
@@ -365,7 +365,10 @@ def table_exists(
365
365
 
366
366
 
367
367
  def create_temp_id_table(
368
- l_ids: list, conn: sa.engine.Connection, int_type="int"
368
+ l_ids: list,
369
+ conn: sa.engine.Connection,
370
+ int_type="int",
371
+ chunksize: int = 1000000,
369
372
  ) -> str:
370
373
  """Creates a temporary table to containing a list of ids.
371
374
 
@@ -377,6 +380,8 @@ def create_temp_id_table(
377
380
  a connection that has been opened
378
381
  int_type : str
379
382
  an SQL string representing the int type
383
+ chunksize : int
384
+ maximum number of ids to be inserted in each INSERT statement
380
385
 
381
386
  Returns
382
387
  -------
@@ -389,9 +394,15 @@ def create_temp_id_table(
389
394
  query_str = f"CREATE TEMP TABLE {table_name}(id {int_type});"
390
395
  conn.execute(sa.text(query_str))
391
396
 
392
- values = ",".join((f"({id})" for id in l_ids))
393
- query_str = f"INSERT INTO {table_name}(id) VALUES {values};"
394
- conn.execute(sa.text(query_str))
397
+ while True:
398
+ l_ids2 = l_ids[:chunksize]
399
+ if len(l_ids2) == 0:
400
+ break
401
+
402
+ values = ",".join((f"({id})" for id in l_ids2))
403
+ query_str = f"INSERT INTO {table_name}(id) VALUES {values};"
404
+ conn.execute(sa.text(query_str))
405
+ l_ids = l_ids[chunksize:]
395
406
 
396
407
  return table_name
397
408
 
mt/sql/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  MAJOR_VERSION = 1
2
2
  MINOR_VERSION = 12
3
- PATCH_VERSION = 2
3
+ PATCH_VERSION = 4
4
4
  version = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
5
5
  __all__ = ['MAJOR_VERSION', 'MINOR_VERSION', 'PATCH_VERSION', 'version']
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: mtsql
3
- Version: 1.12.2
3
+ Version: 1.12.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']
@@ -16,6 +16,7 @@ Requires-Dist: mtbase>=4.31.5
16
16
  Requires-Dist: mtpandas>=1.16.8
17
17
  Dynamic: author
18
18
  Dynamic: home-page
19
+ Dynamic: license-file
19
20
  Dynamic: project-url
20
21
  Dynamic: requires-dist
21
22
  Dynamic: summary
@@ -1,17 +1,17 @@
1
1
  mt/sql/__init__.py,sha256=b7zO50apZxt9Hg2eOkJhRLrXgACR8eS5b-Rphdn5qNQ,44
2
- mt/sql/base.py,sha256=9aTVudlH9_HEq_v7uHV6p6asDuxMidQwAlCRSXDofvY,11967
2
+ mt/sql/base.py,sha256=CPrI28CZcEEp3cBQBg5_9APotlCiF3U6sg3moeUKZVM,12242
3
3
  mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
4
4
  mt/sql/psql.py,sha256=AmXdDVRbvzK7hWK8kysrdiXkAUwSdWmh_OqlWdoNOig,66578
5
5
  mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
6
- mt/sql/version.py,sha256=o4O-Pz81HnYdc-nrvPexrczHaXAhK87fPW1vQTWaWW0,207
6
+ mt/sql/version.py,sha256=bkN4nibKzzaUx5BUpnVjpcWLFEfk1L8db0fFgr6LeZg,207
7
7
  mt/sql/redshift/__init__.py,sha256=S-eRxJWcrvncF7LZXuulCdPV-UERu9eiw6uyDb5aGsM,443
8
8
  mt/sql/redshift/commands.py,sha256=aAxCsp0Nl-RoWAhdTjzuE32Os_H3e_MdNOj12mt47qs,40187
9
9
  mt/sql/redshift/ddl.py,sha256=eUcZj9oIajiE1wKKBAP-V64gYJ7cVnSAt8dLFfluOJA,9777
10
10
  mt/sql/redshift/dialect.py,sha256=g3ie_BiOFoEC7vOcykbfNwBWKDtPzSf4XXpF6glAgik,53452
11
11
  mt/sql/redshift/main.py,sha256=6dwnwNJ1F0_V9o2oqrSOkyN_pAMrgE01CCoqAjoyOME,17116
12
12
  mt/sql/redshift/redshift-ca-bundle.crt,sha256=532qYkOpQOstFE0mdXE1GVtL3v00XDKgZNTr6gK5-KE,8621
13
- mtsql-1.12.2.dist-info/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
14
- mtsql-1.12.2.dist-info/METADATA,sha256=gpavVgTovq9l6LzjRF0wtPRXmwnrghNT9IouER8j4sQ,715
15
- mtsql-1.12.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
16
- mtsql-1.12.2.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
17
- mtsql-1.12.2.dist-info/RECORD,,
13
+ mtsql-1.12.4.dist-info/licenses/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
14
+ mtsql-1.12.4.dist-info/METADATA,sha256=ayP81DwHQYi3zsaKa5xSQBFN4sln3KArWVRiRiAMAU8,737
15
+ mtsql-1.12.4.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
16
+ mtsql-1.12.4.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
17
+ mtsql-1.12.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (80.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5