mtsql 1.12.11__py3-none-any.whl → 1.12.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/psql.py +9 -7
- mt/sql/redshift/dialect.py +16 -16
- mt/sql/redshift/main.py +7 -7
- mt/sql/version.py +1 -1
- {mtsql-1.12.11.dist-info → mtsql-1.12.12.dist-info}/METADATA +1 -1
- {mtsql-1.12.11.dist-info → mtsql-1.12.12.dist-info}/RECORD +9 -9
- {mtsql-1.12.11.dist-info → mtsql-1.12.12.dist-info}/WHEEL +0 -0
- {mtsql-1.12.11.dist-info → mtsql-1.12.12.dist-info}/licenses/LICENSE +0 -0
- {mtsql-1.12.11.dist-info → mtsql-1.12.12.dist-info}/top_level.txt +0 -0
mt/sql/psql.py
CHANGED
|
@@ -197,7 +197,7 @@ def to_sql(
|
|
|
197
197
|
if_exists="fail",
|
|
198
198
|
nb_trials: int = 3,
|
|
199
199
|
logger: tp.Optional[logg.IndentedLoggerAdapter] = None,
|
|
200
|
-
**
|
|
200
|
+
**kwds,
|
|
201
201
|
):
|
|
202
202
|
"""Writes records stored in a DataFrame to a PostgreSQL database.
|
|
203
203
|
|
|
@@ -222,6 +222,8 @@ def to_sql(
|
|
|
222
222
|
number of query trials
|
|
223
223
|
logger: mt.logg.IndentedLoggerAdapter, optional
|
|
224
224
|
logger for debugging
|
|
225
|
+
**kwds : dict
|
|
226
|
+
other keyword arguments to be passed as-is to :func:`pandas.DataFrame.to_sql`
|
|
225
227
|
|
|
226
228
|
Raises
|
|
227
229
|
------
|
|
@@ -241,12 +243,12 @@ def to_sql(
|
|
|
241
243
|
|
|
242
244
|
"""
|
|
243
245
|
|
|
244
|
-
if
|
|
245
|
-
if "index" in
|
|
246
|
+
if kwds:
|
|
247
|
+
if "index" in kwds:
|
|
246
248
|
raise ValueError(
|
|
247
249
|
"The `mt.sql.psql.to_sql()` function does not accept `index` as a keyword."
|
|
248
250
|
)
|
|
249
|
-
if "index_label" in
|
|
251
|
+
if "index_label" in kwds:
|
|
250
252
|
raise ValueError(
|
|
251
253
|
"This `mt.sql.psql.to_sql()` function does not accept `index_label` as a keyword."
|
|
252
254
|
)
|
|
@@ -274,7 +276,7 @@ def to_sql(
|
|
|
274
276
|
index_label=None,
|
|
275
277
|
nb_trials=nb_trials,
|
|
276
278
|
logger=logger,
|
|
277
|
-
**
|
|
279
|
+
**kwds,
|
|
278
280
|
)
|
|
279
281
|
retval = run_func(
|
|
280
282
|
df.to_sql,
|
|
@@ -286,7 +288,7 @@ def to_sql(
|
|
|
286
288
|
index_label=None,
|
|
287
289
|
nb_trials=nb_trials,
|
|
288
290
|
logger=logger,
|
|
289
|
-
**
|
|
291
|
+
**kwds,
|
|
290
292
|
)
|
|
291
293
|
if if_exists == "replace":
|
|
292
294
|
query_str = "ALTER TABLE {} ADD PRIMARY KEY ({});".format(
|
|
@@ -346,7 +348,7 @@ def to_sql(
|
|
|
346
348
|
index_label=None,
|
|
347
349
|
nb_trials=nb_trials,
|
|
348
350
|
logger=logger,
|
|
349
|
-
**
|
|
351
|
+
**kwds,
|
|
350
352
|
)
|
|
351
353
|
|
|
352
354
|
|
mt/sql/redshift/dialect.py
CHANGED
|
@@ -485,7 +485,7 @@ class TIMESTAMPTZ(RedshiftTypeEngine, sa.dialects.postgresql.TIMESTAMP):
|
|
|
485
485
|
|
|
486
486
|
def __init__(self, timezone=True, precision=None):
|
|
487
487
|
# timezone param must be present as it's provided in base class so the
|
|
488
|
-
# object can be instantiated with
|
|
488
|
+
# object can be instantiated with kwds. see
|
|
489
489
|
# :meth:`~sqlalchemy.dialects.postgresql.base.PGDialect._get_column_info`
|
|
490
490
|
super(TIMESTAMPTZ, self).__init__(timezone=True, precision=precision)
|
|
491
491
|
|
|
@@ -506,7 +506,7 @@ class TIMETZ(RedshiftTypeEngine, sa.dialects.postgresql.TIME):
|
|
|
506
506
|
|
|
507
507
|
def __init__(self, timezone=True, precision=None):
|
|
508
508
|
# timezone param must be present as it's provided in base class so the
|
|
509
|
-
# object can be instantiated with
|
|
509
|
+
# object can be instantiated with kwds. see
|
|
510
510
|
# :meth:`~sqlalchemy.dialects.postgresql.base.PGDialect._get_column_info`
|
|
511
511
|
super(TIMETZ, self).__init__(timezone=True, precision=precision)
|
|
512
512
|
|
|
@@ -747,12 +747,12 @@ class RedshiftDDLCompiler(PGDDLCompiler):
|
|
|
747
747
|
"""
|
|
748
748
|
|
|
749
749
|
def post_create_table(self, table):
|
|
750
|
-
|
|
750
|
+
kwds = ["diststyle", "distkey", "sortkey", "interleaved_sortkey"]
|
|
751
751
|
info = table.dialect_options["mtsql_redshift"]
|
|
752
|
-
info = {key: info.get(key) for key in
|
|
752
|
+
info = {key: info.get(key) for key in kwds}
|
|
753
753
|
return get_table_attributes(self.preparer, **info)
|
|
754
754
|
|
|
755
|
-
def get_column_specification(self, column, **
|
|
755
|
+
def get_column_specification(self, column, **kwds):
|
|
756
756
|
colspec = self.preparer.format_column(column)
|
|
757
757
|
|
|
758
758
|
colspec += " " + self.dialect.type_compiler.process(column.type)
|
|
@@ -1156,8 +1156,8 @@ class RedshiftDialectMixin(DefaultDialect):
|
|
|
1156
1156
|
relation_names.append(key.name)
|
|
1157
1157
|
return relation_names
|
|
1158
1158
|
|
|
1159
|
-
def _get_column_info(self, *args, **
|
|
1160
|
-
kw =
|
|
1159
|
+
def _get_column_info(self, *args, **kwds):
|
|
1160
|
+
kw = kwds.copy()
|
|
1161
1161
|
encode = kw.pop("encode", None)
|
|
1162
1162
|
if sa_version >= Version("1.3.16"):
|
|
1163
1163
|
# SQLAlchemy 1.3.16 introduced generated columns,
|
|
@@ -1422,8 +1422,8 @@ class RedshiftDialect(RedshiftDialectMixin, PGDialect):
|
|
|
1422
1422
|
supports_statement_cache = False
|
|
1423
1423
|
use_setinputsizes = False # not implemented in redshift_connector
|
|
1424
1424
|
|
|
1425
|
-
def __init__(self, client_encoding=None, **
|
|
1426
|
-
super(RedshiftDialect, self).__init__(client_encoding=client_encoding, **
|
|
1425
|
+
def __init__(self, client_encoding=None, **kwds):
|
|
1426
|
+
super(RedshiftDialect, self).__init__(client_encoding=client_encoding, **kwds)
|
|
1427
1427
|
self.client_encoding = client_encoding
|
|
1428
1428
|
|
|
1429
1429
|
@classmethod
|
|
@@ -1523,7 +1523,7 @@ class RedshiftDialect(RedshiftDialectMixin, PGDialect):
|
|
|
1523
1523
|
else:
|
|
1524
1524
|
return None
|
|
1525
1525
|
|
|
1526
|
-
def create_connect_args(self, *args, **
|
|
1526
|
+
def create_connect_args(self, *args, **kwds):
|
|
1527
1527
|
"""
|
|
1528
1528
|
Build DB-API compatible connection arguments.
|
|
1529
1529
|
|
|
@@ -1536,7 +1536,7 @@ class RedshiftDialect(RedshiftDialectMixin, PGDialect):
|
|
|
1536
1536
|
"application_name": "sqlalchemy-redshift",
|
|
1537
1537
|
}
|
|
1538
1538
|
cargs, cparams = super(RedshiftDialectMixin, self).create_connect_args(
|
|
1539
|
-
*args, **
|
|
1539
|
+
*args, **kwds
|
|
1540
1540
|
)
|
|
1541
1541
|
# set client_encoding so it is picked up by on_connect(), as
|
|
1542
1542
|
# redshift_connector does not have client_encoding connection parameter
|
|
@@ -1570,7 +1570,7 @@ def gen_columns_from_children(root):
|
|
|
1570
1570
|
|
|
1571
1571
|
|
|
1572
1572
|
@compiles(Delete, "redshift")
|
|
1573
|
-
def visit_delete_stmt(element, compiler, **
|
|
1573
|
+
def visit_delete_stmt(element, compiler, **kwds):
|
|
1574
1574
|
"""
|
|
1575
1575
|
Adds redshift-dialect specific compilation rule for the
|
|
1576
1576
|
delete statement.
|
|
@@ -1635,25 +1635,25 @@ def visit_delete_stmt(element, compiler, **kwargs):
|
|
|
1635
1635
|
# note:
|
|
1636
1636
|
# the tables in the using clause are sorted in the order in
|
|
1637
1637
|
# which they first appear in the where clause.
|
|
1638
|
-
delete_stmt_table = compiler.process(element.table, asfrom=True, **
|
|
1638
|
+
delete_stmt_table = compiler.process(element.table, asfrom=True, **kwds)
|
|
1639
1639
|
|
|
1640
1640
|
if sa_version >= Version("1.4.0"):
|
|
1641
1641
|
if element.whereclause is not None:
|
|
1642
|
-
clause = compiler.process(element.whereclause, **
|
|
1642
|
+
clause = compiler.process(element.whereclause, **kwds)
|
|
1643
1643
|
if clause:
|
|
1644
1644
|
whereclause = " WHERE {clause}".format(clause=clause)
|
|
1645
1645
|
else:
|
|
1646
1646
|
whereclause_tuple = element.get_children()
|
|
1647
1647
|
if whereclause_tuple:
|
|
1648
1648
|
whereclause = " WHERE {clause}".format(
|
|
1649
|
-
clause=compiler.process(*whereclause_tuple, **
|
|
1649
|
+
clause=compiler.process(*whereclause_tuple, **kwds)
|
|
1650
1650
|
)
|
|
1651
1651
|
|
|
1652
1652
|
if whereclause:
|
|
1653
1653
|
usingclause_tables = []
|
|
1654
1654
|
whereclause_columns = gen_columns_from_children(element)
|
|
1655
1655
|
for col in whereclause_columns:
|
|
1656
|
-
table = compiler.process(col.table, asfrom=True, **
|
|
1656
|
+
table = compiler.process(col.table, asfrom=True, **kwds)
|
|
1657
1657
|
if table != delete_stmt_table and table not in usingclause_tables:
|
|
1658
1658
|
usingclause_tables.append(table)
|
|
1659
1659
|
if usingclause_tables:
|
mt/sql/redshift/main.py
CHANGED
|
@@ -418,7 +418,7 @@ def to_sql(
|
|
|
418
418
|
if_exists="fail",
|
|
419
419
|
nb_trials: int = 3,
|
|
420
420
|
logger: tp.Optional[logg.IndentedLoggerAdapter] = None,
|
|
421
|
-
**
|
|
421
|
+
**kwds,
|
|
422
422
|
):
|
|
423
423
|
"""Writes records stored in a DataFrame to a Redshift database.
|
|
424
424
|
|
|
@@ -440,7 +440,7 @@ def to_sql(
|
|
|
440
440
|
number of query trials
|
|
441
441
|
logger: mt.logg.IndentedLoggerAdapter, optional
|
|
442
442
|
logger for debugging
|
|
443
|
-
|
|
443
|
+
**kwds : dict
|
|
444
444
|
keyword arguments passed as-is to :func:`pandas.DataFrame.to_sql`
|
|
445
445
|
|
|
446
446
|
Raises
|
|
@@ -460,12 +460,12 @@ def to_sql(
|
|
|
460
460
|
|
|
461
461
|
"""
|
|
462
462
|
|
|
463
|
-
if
|
|
464
|
-
if "index" in
|
|
463
|
+
if kwds:
|
|
464
|
+
if "index" in kwds:
|
|
465
465
|
raise ValueError(
|
|
466
466
|
"The `mt.sql.psql.to_sql()` function does not accept `index` as a keyword."
|
|
467
467
|
)
|
|
468
|
-
if "index_label" in
|
|
468
|
+
if "index_label" in kwds:
|
|
469
469
|
raise ValueError(
|
|
470
470
|
"This `mt.sql.psql.to_sql()` function does not accept `index_label` as a keyword."
|
|
471
471
|
)
|
|
@@ -490,7 +490,7 @@ def to_sql(
|
|
|
490
490
|
index_label=None,
|
|
491
491
|
nb_trials=nb_trials,
|
|
492
492
|
logger=logger,
|
|
493
|
-
**
|
|
493
|
+
**kwds,
|
|
494
494
|
)
|
|
495
495
|
|
|
496
496
|
if if_exists == "replace":
|
|
@@ -507,7 +507,7 @@ def to_sql(
|
|
|
507
507
|
index_label=None,
|
|
508
508
|
nb_trials=nb_trials,
|
|
509
509
|
logger=logger,
|
|
510
|
-
**
|
|
510
|
+
**kwds,
|
|
511
511
|
)
|
|
512
512
|
|
|
513
513
|
return retval
|
mt/sql/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mtsql
|
|
3
|
-
Version: 1.12.
|
|
3
|
+
Version: 1.12.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']
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
mt/sql/__init__.py,sha256=b7zO50apZxt9Hg2eOkJhRLrXgACR8eS5b-Rphdn5qNQ,44
|
|
2
2
|
mt/sql/base.py,sha256=rEDlXivxH06ZsdpSXkraiqBCDDYh3FLVZfuH-spVw8w,12976
|
|
3
3
|
mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
|
|
4
|
-
mt/sql/psql.py,sha256=
|
|
4
|
+
mt/sql/psql.py,sha256=w5klr_2lUZnAFee-Fzbn3G8jdYcf_iX4N_GfAGIdsMI,66670
|
|
5
5
|
mt/sql/sqlite.py,sha256=T2ak_hhNi_zRfpg_gp8JhNHn7D2kl4i-Ey6-9ANMtz0,8678
|
|
6
|
-
mt/sql/version.py,sha256=
|
|
6
|
+
mt/sql/version.py,sha256=7Ierb-IwvIgb7So3QUVyOb206Eut5KTX02AND5UIhfc,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
|
-
mt/sql/redshift/dialect.py,sha256
|
|
11
|
-
mt/sql/redshift/main.py,sha256=
|
|
10
|
+
mt/sql/redshift/dialect.py,sha256=-0JjJubZZHRw0abhl6H6rKWaUE9pKtGwAuX-62T0e_c,53399
|
|
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.
|
|
14
|
-
mtsql-1.12.
|
|
15
|
-
mtsql-1.12.
|
|
16
|
-
mtsql-1.12.
|
|
17
|
-
mtsql-1.12.
|
|
13
|
+
mtsql-1.12.12.dist-info/licenses/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
|
|
14
|
+
mtsql-1.12.12.dist-info/METADATA,sha256=pDALCX7SklLIq1omFMmUKOx9cYkaBVXHTYXXDIFmaE8,740
|
|
15
|
+
mtsql-1.12.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
mtsql-1.12.12.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
|
|
17
|
+
mtsql-1.12.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|