mtsql 1.12.29__py3-none-any.whl → 1.12.30__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
@@ -30,6 +30,7 @@ __all__ = [
30
30
  "temp_table_drop",
31
31
  "to_temp_table",
32
32
  "find_common_ids",
33
+ "remove_records_by_id",
33
34
  ]
34
35
 
35
36
 
@@ -544,3 +545,43 @@ def find_common_ids(
544
545
  l_commonIds = df_common["id"].tolist()
545
546
 
546
547
  return l_commonIds
548
+
549
+
550
+ def remove_records_by_id(
551
+ l_ids: tp.List[int],
552
+ frame_name: str,
553
+ engine: sa.engine.Engine,
554
+ schema: tp.Optional[str] = None,
555
+ id_col: str = "id",
556
+ logger: tp.Optional[logg.IndentedLoggerAdapter] = None,
557
+ ):
558
+ """Removes records from a frame by a list of ids.
559
+
560
+ Parameters
561
+ ----------
562
+ l_ids : list of int
563
+ list of ids to be removed
564
+ frame_name : str
565
+ name of the frame to be modified
566
+ engine : sqlalchemy.engine.Engine
567
+ connection engine to the server
568
+ schema : str, optional
569
+ schema of the frame. If None, the default schema is used.
570
+ id_col : str
571
+ name of the id column in the frame
572
+ logger : mt.logg.IndentedLoggerAdapter, optional
573
+ logger for debugging
574
+ """
575
+
576
+ with conn_ctx(engine) as conn:
577
+ temp_table = create_temp_id_table(l_ids, conn, logger=logger)
578
+
579
+ full_frame_name = frame_sql(frame_name, schema=schema)
580
+
581
+ sql = f"""
582
+ DELETE FROM {full_frame_name}
583
+ USING {temp_table} AS t
584
+ WHERE {full_frame_name}.{id_col} = t.id;
585
+ """
586
+
587
+ exec_sql(sql, conn, logger=logger)
mt/sql/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  MAJOR_VERSION = 1
2
2
  MINOR_VERSION = 12
3
- PATCH_VERSION = 29
3
+ PATCH_VERSION = 30
4
4
  version = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
5
5
  __all__ = ['MAJOR_VERSION', 'MINOR_VERSION', 'PATCH_VERSION', 'version']
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mtsql
3
- Version: 1.12.29
3
+ Version: 1.12.30
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
- Author: ['Minh-Tri Pham']
6
+ Author: Minh-Tri Pham
7
7
  Project-URL: Documentation, https://mtdoc.readthedocs.io/en/latest/mt.sql/mt.sql.html
8
8
  Project-URL: Source Code, https://github.com/inteplus/mtsql
9
9
  License-File: LICENSE
@@ -12,7 +12,7 @@ Requires-Dist: tzlocal
12
12
  Requires-Dist: tqdm
13
13
  Requires-Dist: psycopg[binary]
14
14
  Requires-Dist: redshift_connector>=2.1.5
15
- Requires-Dist: mtbase>=4.32.34
15
+ Requires-Dist: mtbase>=4.3.2
16
16
  Requires-Dist: mtpandas>=1.17.16
17
17
  Dynamic: author
18
18
  Dynamic: home-page
@@ -1,17 +1,17 @@
1
1
  mt/sql/__init__.py,sha256=b7zO50apZxt9Hg2eOkJhRLrXgACR8eS5b-Rphdn5qNQ,44
2
- mt/sql/base.py,sha256=YM7BnNf1e3WizzH5Amg5xK-L5s0w9Cnl9-90htUqJlg,15096
2
+ mt/sql/base.py,sha256=AAoiWIpN8jyHdnfbmUvee6iU2pxo7pDcgO5dLrsybrY,16243
3
3
  mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
4
4
  mt/sql/psql.py,sha256=U8XEyg4rQYr5gm8KohRWrpCNJKl5WC1yxJMBkkm1k_A,68125
5
5
  mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
6
- mt/sql/version.py,sha256=I7DJlgmw1b2vkxA_AWJYjd0FWS4W3BxvUIL3cHr587E,208
6
+ mt/sql/version.py,sha256=ATznhpd6AvkQUj3yf0sDQ4RYHO5ZWLiQdaKgfHdbxlE,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.29.dist-info/licenses/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
14
- mtsql-1.12.29.dist-info/METADATA,sha256=dsOJv6kpa6gxLeky_Hsw939aE8bK3F8EMel1g4S1Xyo,740
15
- mtsql-1.12.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- mtsql-1.12.29.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
17
- mtsql-1.12.29.dist-info/RECORD,,
13
+ mtsql-1.12.30.dist-info/licenses/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
14
+ mtsql-1.12.30.dist-info/METADATA,sha256=mxs0fj1WO1myL6Zlf3iTyPSDDe6Do4TnZtif48dPbms,734
15
+ mtsql-1.12.30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ mtsql-1.12.30.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
17
+ mtsql-1.12.30.dist-info/RECORD,,