mtsql 1.12.27__py3-none-any.whl → 1.12.28__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 +34 -0
- mt/sql/version.py +1 -1
- {mtsql-1.12.27.dist-info → mtsql-1.12.28.dist-info}/METADATA +1 -1
- {mtsql-1.12.27.dist-info → mtsql-1.12.28.dist-info}/RECORD +7 -7
- {mtsql-1.12.27.dist-info → mtsql-1.12.28.dist-info}/WHEEL +0 -0
- {mtsql-1.12.27.dist-info → mtsql-1.12.28.dist-info}/licenses/LICENSE +0 -0
- {mtsql-1.12.27.dist-info → mtsql-1.12.28.dist-info}/top_level.txt +0 -0
mt/sql/psql.py
CHANGED
|
@@ -36,6 +36,7 @@ __all__ = [
|
|
|
36
36
|
"refresh_matview",
|
|
37
37
|
"drop_matview",
|
|
38
38
|
"frame_exists",
|
|
39
|
+
"count_estimate",
|
|
39
40
|
"drop_frame",
|
|
40
41
|
"list_columns_ext",
|
|
41
42
|
"list_columns",
|
|
@@ -969,6 +970,39 @@ def frame_exists(
|
|
|
969
970
|
)
|
|
970
971
|
|
|
971
972
|
|
|
973
|
+
def count_estimate(
|
|
974
|
+
frame_name,
|
|
975
|
+
engine,
|
|
976
|
+
schema: tp.Optional[str] = None,
|
|
977
|
+
nb_trials: int = 3,
|
|
978
|
+
logger: tp.Optional[logg.IndentedLoggerAdapter] = None,
|
|
979
|
+
):
|
|
980
|
+
"""Gives an estimate of the number of rows of a frame.
|
|
981
|
+
|
|
982
|
+
Parameters
|
|
983
|
+
----------
|
|
984
|
+
frame_name: str
|
|
985
|
+
name of table or view
|
|
986
|
+
engine: sqlalchemy.engine.Engine
|
|
987
|
+
an sqlalchemy connection engine created by function `create_engine()`
|
|
988
|
+
schema: str or None
|
|
989
|
+
a valid schema name returned from `list_schemas()`
|
|
990
|
+
nb_trials: int
|
|
991
|
+
number of query trials
|
|
992
|
+
logger: mt.logg.IndentedLoggerAdapter, optional
|
|
993
|
+
logger for debugging
|
|
994
|
+
|
|
995
|
+
Returns
|
|
996
|
+
-------
|
|
997
|
+
retval: int
|
|
998
|
+
the estimated number of rows
|
|
999
|
+
"""
|
|
1000
|
+
frame_sql_str = frame_sql(frame_name, schema=schema)
|
|
1001
|
+
query_str = f"SELECT reltuples::bigint FROM pg_class WHERE oid = '{frame_sql_str}'::regclass;"
|
|
1002
|
+
df = read_sql(query_str, engine, nb_trials=nb_trials, logger=logger)
|
|
1003
|
+
return df.iloc[0]["reltuples"]
|
|
1004
|
+
|
|
1005
|
+
|
|
972
1006
|
def drop_frame(
|
|
973
1007
|
frame_name,
|
|
974
1008
|
engine,
|
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.28
|
|
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=S44nryyeguGNnzdf5ETmKXb9ewbAveiGYhEXVoS7lC8,13732
|
|
3
3
|
mt/sql/mysql.py,sha256=n2ENDctdUqZuSaDAcrqZYtPtawq3Wx4dOPCRsCB5Q4w,4894
|
|
4
|
-
mt/sql/psql.py,sha256=
|
|
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=
|
|
6
|
+
mt/sql/version.py,sha256=s9O6vZP85_qckYPCAa8UMcuMzYn1fIdaCEIpTTQIoHw,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.
|
|
14
|
-
mtsql-1.12.
|
|
15
|
-
mtsql-1.12.
|
|
16
|
-
mtsql-1.12.
|
|
17
|
-
mtsql-1.12.
|
|
13
|
+
mtsql-1.12.28.dist-info/licenses/LICENSE,sha256=PojkRlQzTT5Eg6Nj03XoIVEefN3u8iiIFf1p4rqe_t4,1070
|
|
14
|
+
mtsql-1.12.28.dist-info/METADATA,sha256=9Kx_mlxJwgCMqwBM8CO3YYNzzz3fkATwYPW8Fcm7xWg,740
|
|
15
|
+
mtsql-1.12.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
mtsql-1.12.28.dist-info/top_level.txt,sha256=WcqGFu9cV7iMZg09iam8eNxUvGpLSKKF2Iubf6SJVOo,3
|
|
17
|
+
mtsql-1.12.28.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|