mtsql 1.11.10__py3-none-any.whl → 1.11.11__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
@@ -82,7 +82,7 @@ def run_func(
82
82
  with logger.scoped_warn(msg):
83
83
  logger.warn_last_exception()
84
84
  raise RuntimeError(
85
- f"Attempted {nb_trials} times to execute `{func.__module__}.{(func.__name__)}` but failed."
85
+ f"Attempted {nb_trials} times to execute `{func.__module__}.{func.__name__}` but failed."
86
86
  )
87
87
 
88
88
 
mt/sql/redshift.py CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import sqlalchemy as sa
4
4
  from mt import tp, np, pd, logg
5
+ from mt.base import LogicError
5
6
 
6
7
  from .base import *
7
8
  from .psql import compliance_check
@@ -558,29 +559,36 @@ def conform(
558
559
  df = df[columns].copy()
559
560
 
560
561
  for x in table_decl.columns:
561
- if isinstance(x.type, sa.BigInteger):
562
- dtype = pd.Int64Dtype() if x.nullable else np.int64
563
- elif isinstance(x.type, sa.SmallInteger):
564
- dtype = pd.Int16Dtype() if x.nullable else np.int16
565
- elif isinstance(x.type, sa.Integer):
566
- dtype = pd.Int32Dtype() if x.nullable else np.int32
567
- elif isinstance(x.type, sa.String):
568
- dtype = str
569
- elif isinstance(x.type, sa.REAL):
570
- dtype = np.float32
571
- elif isinstance(x.type, sa.Float):
572
- dtype = float
573
- elif isinstance(x.type, sa.Boolean):
574
- dtype = pd.BooleanDtype() if x.nullable else np.bool
575
- elif isinstance(x.type, sa.DateTime):
576
- dtype = pd.Timestamp
577
- else:
578
- raise NotImplementedError(
579
- "Unable to conform table declaration '{table_decl.name}' column '{x.name}' with type '{type(x.type)}'."
562
+ try:
563
+ if isinstance(x.type, sa.BigInteger):
564
+ dtype = pd.Int64Dtype() if x.nullable else np.int64
565
+ elif isinstance(x.type, sa.SmallInteger):
566
+ dtype = pd.Int16Dtype() if x.nullable else np.int16
567
+ elif isinstance(x.type, sa.Integer):
568
+ dtype = pd.Int32Dtype() if x.nullable else np.int32
569
+ elif isinstance(x.type, sa.String):
570
+ dtype = str
571
+ elif isinstance(x.type, sa.REAL):
572
+ dtype = np.float32
573
+ elif isinstance(x.type, sa.Float):
574
+ dtype = float
575
+ elif isinstance(x.type, sa.Boolean):
576
+ dtype = pd.BooleanDtype() if x.nullable else np.bool
577
+ elif isinstance(x.type, sa.DateTime):
578
+ dtype = pd.Timestamp
579
+ else:
580
+ raise NotImplementedError(
581
+ "Unable to conform table declaration '{table_decl.name}' column '{x.name}' with type '{type(x.type)}'."
582
+ )
583
+ if dtype is pd.Timestamp:
584
+ df[x.name] = pd.to_datetime(df[x.name])
585
+ else:
586
+ df[x.name] = df[x.name].astype(dtype)
587
+ except e:
588
+ raise LogicError(
589
+ "Cannot convert column dtype.",
590
+ debug={"name": x.name, "dtype": dtype},
591
+ causing_error=e,
580
592
  )
581
- if dtype is pd.Timestamp:
582
- df[x.name] = pd.to_datetime(df[x.name])
583
- else:
584
- df[x.name] = df[x.name].astype(dtype)
585
593
 
586
594
  return df
mt/sql/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  MAJOR_VERSION = 1
2
2
  MINOR_VERSION = 11
3
- PATCH_VERSION = 10
3
+ PATCH_VERSION = 11
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.1
2
2
  Name: mtsql
3
- Version: 1.11.10
3
+ Version: 1.11.11
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=qR9ggHU7ae_c3Zj6bm6feFe8EQymGjwAw9rQZ_j0GOo,11968
3
+ mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
4
+ mt/sql/psql.py,sha256=tzsIN2XyBJX8t7p0D2yXgEQwUTkTcDzllI4HunCfq3s,66345
5
+ mt/sql/redshift.py,sha256=H_cCrUKT2hpia0K3YjG4NlMh64myKpKcJG2z5F914xI,17376
6
+ mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
7
+ mt/sql/version.py,sha256=2KNmXEN9sYinBxV5cXGLWcbPNk7UZ9xzj7ZMFrn5Qf4,208
8
+ mtsql-1.11.11.dist-info/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
9
+ mtsql-1.11.11.dist-info/METADATA,sha256=auiLPpF_3sTyqj_qXw9e9MCHkeL1pKqyfzjopqiHimI,580
10
+ mtsql-1.11.11.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
11
+ mtsql-1.11.11.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
12
+ mtsql-1.11.11.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.5.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- mt/sql/__init__.py,sha256=b7zO50apZxt9Hg2eOkJhRLrXgACR8eS5b-Rphdn5qNQ,44
2
- mt/sql/base.py,sha256=utA0nUZB-odP_SZO5LhDRFkmqn25pNt2AoLsK02Os8o,11970
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=_rIt6HbyTo2QHHYcbuEAaxXlBLfuxwL5jVi7XIRbSY4,208
8
- mtsql-1.11.10.dist-info/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
9
- mtsql-1.11.10.dist-info/METADATA,sha256=yK4GDKtRa8hqjJr3uqVCUpfKHTg_dFmhU-MXHXe3iMM,580
10
- mtsql-1.11.10.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
11
- mtsql-1.11.10.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
12
- mtsql-1.11.10.dist-info/RECORD,,