mtsql 1.12.24__py3-none-any.whl → 1.12.25__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/psql.py CHANGED
@@ -640,7 +640,7 @@ def rename_table(
640
640
  nb_trials: int = 3,
641
641
  logger: tp.Optional[logg.IndentedLoggerAdapter] = None,
642
642
  ):
643
- """Renames a table of a schema.
643
+ """Renames a (foreign) table of a schema.
644
644
 
645
645
  Parameters
646
646
  ----------
@@ -653,7 +653,7 @@ def rename_table(
653
653
  schema : str or None
654
654
  a valid schema name returned from `list_schemas()`
655
655
  foreign : bool
656
- whether the table to rename to is a foreign table
656
+ whether the table to rename is a foreign table
657
657
  nb_trials : int
658
658
  number of query trials
659
659
  logger : mt.logg.IndentedLoggerAdapter, optional
@@ -717,21 +717,24 @@ def drop_table(
717
717
  table_name,
718
718
  engine,
719
719
  schema: tp.Optional[str] = None,
720
- restrict=True,
720
+ foreign: bool = False,
721
+ restrict: bool = True,
721
722
  nb_trials: int = 3,
722
723
  logger: tp.Optional[logg.IndentedLoggerAdapter] = None,
723
724
  ):
724
- """Drops a table if it exists, with restrict or cascade options.
725
+ """Drops a (foreign) table if it exists, with restrict or cascade options.
725
726
 
726
727
  Parameters
727
728
  ----------
728
729
  table_name : str
729
730
  table name
730
- engine: sqlalchemy.engine.Engine
731
+ engine : sqlalchemy.engine.Engine
731
732
  an sqlalchemy connection engine created by function `create_engine()`
732
- schema: str or None
733
+ schema : str or None
733
734
  a valid schema name returned from `list_schemas()`
734
- restrict: bool
735
+ foreign : bool
736
+ whether the table to drop is a foreign table
737
+ restrict : bool
735
738
  If True, refuses to drop table if there is any object depending on it. Otherwise it is the
736
739
  'cascade' option which allows you to remove those dependent objects together with the table
737
740
  automatically.
@@ -745,9 +748,11 @@ def drop_table(
745
748
  whatever exec_sql() returns
746
749
  """
747
750
  frame_sql_str = frame_sql(table_name, schema=schema)
748
- query_str = "DROP TABLE IF EXISTS {} {};".format(
749
- frame_sql_str, "RESTRICT" if restrict else "CASCADE"
750
- )
751
+ if foreign:
752
+ query_str = "DROP FOREIGN TABLE "
753
+ else:
754
+ query_str = "DROP TABLE "
755
+ query_str += f'IF EXISTS {frame_sql_str} {"RESTRICT" if restrict else "CASCADE"};'
751
756
  return exec_sql(query_str, engine, nb_trials=nb_trials, logger=logger)
752
757
 
753
758
 
mt/sql/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  MAJOR_VERSION = 1
2
2
  MINOR_VERSION = 12
3
- PATCH_VERSION = 24
3
+ PATCH_VERSION = 25
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
1
  Metadata-Version: 2.4
2
2
  Name: mtsql
3
- Version: 1.12.24
3
+ Version: 1.12.25
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
2
  mt/sql/base.py,sha256=j2fzeGUdh-TnvgotuWOmTM-A0pqBg31z2c19bH5E_xk,13504
3
3
  mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
4
- mt/sql/psql.py,sha256=FSsWCej1zoYHtTkW3zG2KgcYvr7nNGLb8tK0IbGyckQ,66915
4
+ mt/sql/psql.py,sha256=8gWsF6ZobwkAxHsfecF95Em_cAlMitHHdQzinZLCi6s,67110
5
5
  mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
6
- mt/sql/version.py,sha256=72gvcsidDjkfqwriayY0JSOjweNCSpGWzCnmf_B90Dc,208
6
+ mt/sql/version.py,sha256=fESKN3a-51Gk518u42eRfS6jc2qynXacnonQdAruWec,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.24.dist-info/licenses/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
14
- mtsql-1.12.24.dist-info/METADATA,sha256=wCqtyccICAKaTXRyjG3vCx8kUolNCMcJMsGxxJ5pH80,740
15
- mtsql-1.12.24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- mtsql-1.12.24.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
17
- mtsql-1.12.24.dist-info/RECORD,,
13
+ mtsql-1.12.25.dist-info/licenses/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
14
+ mtsql-1.12.25.dist-info/METADATA,sha256=nMGzCZOmjrDiBh9wWHes41XqZ2Q9nvDcsdzNI1ln8tk,740
15
+ mtsql-1.12.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ mtsql-1.12.25.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
17
+ mtsql-1.12.25.dist-info/RECORD,,