zaturn 0.1.5__py3-none-any.whl → 0.1.7__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.
- zaturn/config.py +5 -1
- zaturn/core.py +3 -3
- zaturn/query_utils.py +9 -7
- {zaturn-0.1.5.dist-info → zaturn-0.1.7.dist-info}/METADATA +4 -2
- zaturn-0.1.7.dist-info/RECORD +12 -0
- {zaturn-0.1.5.dist-info → zaturn-0.1.7.dist-info}/WHEEL +1 -1
- zaturn-0.1.5.dist-info/RECORD +0 -12
- {zaturn-0.1.5.dist-info → zaturn-0.1.7.dist-info}/entry_points.txt +0 -0
- {zaturn-0.1.5.dist-info → zaturn-0.1.7.dist-info}/licenses/LICENSE +0 -0
- {zaturn-0.1.5.dist-info → zaturn-0.1.7.dist-info}/top_level.txt +0 -0
zaturn/config.py
CHANGED
@@ -59,8 +59,12 @@ for s in source_list:
|
|
59
59
|
elif source.startswith('postgresql://'):
|
60
60
|
source_type = 'postgresql'
|
61
61
|
source_name = source.split('/')[-1].split('?')[0]
|
62
|
-
elif source.startswith("mysql+pymysql://"):
|
62
|
+
elif source.startswith("mysql://") or source.startswith("mysql+pymysql://"):
|
63
63
|
source_type = 'mysql'
|
64
|
+
s = s.replace('mysql://', 'mysql+pymysql://')
|
65
|
+
source_name = source.split('/')[-1].split('?')[0]
|
66
|
+
elif source.startswith('clickhouse://'):
|
67
|
+
source_type = 'clickhouse'
|
64
68
|
source_name = source.split('/')[-1].split('?')[0]
|
65
69
|
elif source.endswith(".duckdb"):
|
66
70
|
source_type = "duckdb"
|
zaturn/core.py
CHANGED
@@ -62,7 +62,7 @@ def _list_tables(source_id: str):
|
|
62
62
|
if col.startswith("Tables_in_"):
|
63
63
|
return result[col].to_list()
|
64
64
|
|
65
|
-
case "duckdb" | "csv" | "parquet":
|
65
|
+
case "duckdb" | "csv" | "parquet" | "clickhouse":
|
66
66
|
result = query_utils.execute_query(source, "SHOW TABLES")
|
67
67
|
return result['name'].to_list()
|
68
68
|
|
@@ -86,7 +86,7 @@ def describe_table(source_id: str, table_name: str) -> str:
|
|
86
86
|
match source['type']:
|
87
87
|
case 'sqlite':
|
88
88
|
result = query_utils.execute_query(source,
|
89
|
-
f
|
89
|
+
f'PRAGMA table_info({table_name});'
|
90
90
|
)
|
91
91
|
return result.to_markdown(index=False)
|
92
92
|
|
@@ -96,7 +96,7 @@ def describe_table(source_id: str, table_name: str) -> str:
|
|
96
96
|
)
|
97
97
|
return result.to_markdown(index=False)
|
98
98
|
|
99
|
-
case "mysql" | "duckdb" | "csv" | "parquet":
|
99
|
+
case "mysql" | "duckdb" | "csv" | "parquet" | "clickhouse":
|
100
100
|
result = query_utils.execute_query(source,
|
101
101
|
f"DESCRIBE {table_name};"
|
102
102
|
)
|
zaturn/query_utils.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import clickhouse_connect
|
1
2
|
import duckdb
|
2
3
|
import numpy as np
|
3
4
|
import os
|
@@ -12,16 +13,11 @@ from zaturn import config
|
|
12
13
|
def execute_query(source: dict, query: str):
|
13
14
|
"""Run the query using the appropriate engine and read only config"""
|
14
15
|
url = source['url']
|
15
|
-
|
16
|
+
|
16
17
|
match source['type']:
|
17
18
|
case "sqlite":
|
18
|
-
if "mode=ro" in url:
|
19
|
-
pass
|
20
|
-
elif '?' in url:
|
21
|
-
url += '&mode=ro'
|
22
|
-
else:
|
23
|
-
url += '?mode=ro'
|
24
19
|
with sqlalchemy.create_engine(url).connect() as conn:
|
20
|
+
conn.execute(sqlalchemy.text('PRAGMA query_only = ON;'))
|
25
21
|
result = conn.execute(sqlalchemy.text(query))
|
26
22
|
return pd.DataFrame(result)
|
27
23
|
|
@@ -31,6 +27,7 @@ def execute_query(source: dict, query: str):
|
|
31
27
|
session.autoflush = False
|
32
28
|
session.autocommit = False
|
33
29
|
session.flush = lambda *args: None
|
30
|
+
session.execute(sqlalchemy.text('SET SESSION TRANSACTION READ ONLY;'))
|
34
31
|
result = session.execute(sqlalchemy.text(query))
|
35
32
|
return pd.DataFrame(result)
|
36
33
|
|
@@ -46,6 +43,11 @@ def execute_query(source: dict, query: str):
|
|
46
43
|
result = conn.execute(sqlalchemy.text(query))
|
47
44
|
return pd.DataFrame(result)
|
48
45
|
|
46
|
+
case "clickhouse":
|
47
|
+
client = clickhouse_connect.get_client(dsn=url)
|
48
|
+
client.query('SET readonly=1;')
|
49
|
+
return client.query_df(query, use_extended_dtypes=False)
|
50
|
+
|
49
51
|
case "duckdb":
|
50
52
|
conn = duckdb.connect(url, read_only=True)
|
51
53
|
return conn.execute(query).df()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: zaturn
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.7
|
4
4
|
Summary: AI Data Analysis MCP
|
5
5
|
Author-email: Karthik Devan <krtdvn@gmail.com>
|
6
6
|
Maintainer-email: Karthik Devan <krtdvn@gmail.com>
|
@@ -9,6 +9,7 @@ Project-URL: Issues, https://github.com/kdqed/zaturn/issues
|
|
9
9
|
Requires-Python: >=3.11
|
10
10
|
Description-Content-Type: text/markdown
|
11
11
|
License-File: LICENSE
|
12
|
+
Requires-Dist: clickhouse-connect>=0.8.17
|
12
13
|
Requires-Dist: cryptography>=44.0.2
|
13
14
|
Requires-Dist: duckdb>=1.2.1
|
14
15
|
Requires-Dist: fastmcp>=0.4.1
|
@@ -56,7 +57,7 @@ https://github.com/user-attachments/assets/d42dc433-e5ec-4b3e-bef0-5cfc097396ab
|
|
56
57
|
|
57
58
|
### Multiple Data Sources
|
58
59
|
Zaturn can currently connect to the following data sources:
|
59
|
-
- SQL Databases: PostgreSQL, SQLite, DuckDB, MySQL
|
60
|
+
- SQL Databases: PostgreSQL, SQLite, DuckDB, MySQL, ClickHouse
|
60
61
|
- Files: CSV, Parquet
|
61
62
|
|
62
63
|
Connectors for more data sources are being added.
|
@@ -105,6 +106,7 @@ OR add a `sources.txt` to the Zaturn config directory:
|
|
105
106
|
```
|
106
107
|
postgresql://username:password@host:port/dbname
|
107
108
|
mysql+pymysql://username:password@host:3306/dbname
|
109
|
+
clickhouse://username:password@host:port/dbname
|
108
110
|
sqlite:////full/path/to/sample_dbs/northwind.db
|
109
111
|
/full/path/to/sample_dbs/titanic.parquet
|
110
112
|
/full/path/to/sample_dbs/ny_aq.csv
|
@@ -0,0 +1,12 @@
|
|
1
|
+
zaturn/__init__.py,sha256=v4t5fkRuIJFE-SBxCa5pBjZv0EoC0eWK75nU9iaa7Rg,267
|
2
|
+
zaturn/config.py,sha256=qdFy7GyGyXO-rEyqb8kO3wym3DEk2nQEiz-JscDKjaw,3446
|
3
|
+
zaturn/core.py,sha256=MNB37smt4wkdHCTsZECesrksnx0FnCnHBw4kkWOTvTQ,4671
|
4
|
+
zaturn/query_utils.py,sha256=4o37eGV8X1sbYvme_jKaPX8hdlynfzMK_0qCSf6XZlo,3031
|
5
|
+
zaturn/visualizations.py,sha256=0ON70D_mK4o0oyfEKqAhr2jkKWz_5-kNKkD6_TGBR9k,5014
|
6
|
+
zaturn/example_data/all_pokemon_data.csv,sha256=SUlGHHWbehuLg-ch1YUrQ6-xBtqHGw6rIkyn70fAgCk,130893
|
7
|
+
zaturn-0.1.7.dist-info/licenses/LICENSE,sha256=mZSuFlbEBZGl0-8ULRMLdRDbhau5hrWRNQOjytYeaug,1070
|
8
|
+
zaturn-0.1.7.dist-info/METADATA,sha256=b_pULTQiosZBRg6lZSAWVD23HxRmjercbL3bj06wOHE,7179
|
9
|
+
zaturn-0.1.7.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
10
|
+
zaturn-0.1.7.dist-info/entry_points.txt,sha256=N1UZC2zvod92_Brs4A2xZiAnt-iGLBNryglXfwhxfj4,43
|
11
|
+
zaturn-0.1.7.dist-info/top_level.txt,sha256=KLUnwQwVZkfd5YCnnqR35MOOs8KLhanPGelvmRo2MVA,7
|
12
|
+
zaturn-0.1.7.dist-info/RECORD,,
|
zaturn-0.1.5.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
zaturn/__init__.py,sha256=v4t5fkRuIJFE-SBxCa5pBjZv0EoC0eWK75nU9iaa7Rg,267
|
2
|
-
zaturn/config.py,sha256=gF5M6Agmixw2A4vpWqIF3ICVnClPeASA51dhp1bkk04,3221
|
3
|
-
zaturn/core.py,sha256=9zcKb0FbkgGkDtWfBA6_O5NQf6GVKG69HrqOr5nhsLU,4641
|
4
|
-
zaturn/query_utils.py,sha256=zyQjcRnPKGHZdf0XHzQeMxHw9vieZIwXhBbVGP87ml4,2801
|
5
|
-
zaturn/visualizations.py,sha256=0ON70D_mK4o0oyfEKqAhr2jkKWz_5-kNKkD6_TGBR9k,5014
|
6
|
-
zaturn/example_data/all_pokemon_data.csv,sha256=SUlGHHWbehuLg-ch1YUrQ6-xBtqHGw6rIkyn70fAgCk,130893
|
7
|
-
zaturn-0.1.5.dist-info/licenses/LICENSE,sha256=mZSuFlbEBZGl0-8ULRMLdRDbhau5hrWRNQOjytYeaug,1070
|
8
|
-
zaturn-0.1.5.dist-info/METADATA,sha256=Vl68nwLT5NVIdtRRMnV6ncyE4oTIoC3GF_eGJcLN-uA,7077
|
9
|
-
zaturn-0.1.5.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
10
|
-
zaturn-0.1.5.dist-info/entry_points.txt,sha256=N1UZC2zvod92_Brs4A2xZiAnt-iGLBNryglXfwhxfj4,43
|
11
|
-
zaturn-0.1.5.dist-info/top_level.txt,sha256=KLUnwQwVZkfd5YCnnqR35MOOs8KLhanPGelvmRo2MVA,7
|
12
|
-
zaturn-0.1.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|