mtsql 1.11.10__py3-none-any.whl → 1.11.12__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 +1 -1
- mt/sql/redshift.py +31 -23
- mt/sql/version.py +1 -1
- {mtsql-1.11.10.dist-info → mtsql-1.11.12.dist-info}/METADATA +1 -1
- mtsql-1.11.12.dist-info/RECORD +12 -0
- {mtsql-1.11.10.dist-info → mtsql-1.11.12.dist-info}/WHEEL +1 -1
- mtsql-1.11.10.dist-info/RECORD +0 -12
- {mtsql-1.11.10.dist-info → mtsql-1.11.12.dist-info}/LICENSE +0 -0
- {mtsql-1.11.10.dist-info → mtsql-1.11.12.dist-info}/top_level.txt +0 -0
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__}.{
|
|
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
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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 Exception as 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,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mtsql
|
|
3
|
-
Version: 1.11.
|
|
3
|
+
Version: 1.11.12
|
|
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=Xtxy4pmqVfiXARGNOmq2dEG9eRLmaINRJIXvctLIJHg,17389
|
|
6
|
+
mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
|
|
7
|
+
mt/sql/version.py,sha256=pqOt4EFHe69mP9LpnUwSE536jna7oEvyHugaySEaxx0,208
|
|
8
|
+
mtsql-1.11.12.dist-info/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
|
|
9
|
+
mtsql-1.11.12.dist-info/METADATA,sha256=QeUuCizrVY8r3CPnD4gXPzQbGdyU-T3pds_LZYqM37o,580
|
|
10
|
+
mtsql-1.11.12.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
11
|
+
mtsql-1.11.12.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
|
|
12
|
+
mtsql-1.11.12.dist-info/RECORD,,
|
mtsql-1.11.10.dist-info/RECORD
DELETED
|
@@ -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,,
|
|
File without changes
|
|
File without changes
|