thds.core 1.45.20251007062722__py3-none-any.whl → 1.46.20251008013227__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.
Potentially problematic release.
This version of thds.core might be problematic. Click here for more details.
- thds/core/sqlite/__init__.py +1 -1
- thds/core/sqlite/meta.py +40 -2
- thds/core/sqlite/types.py +1 -1
- {thds_core-1.45.20251007062722.dist-info → thds_core-1.46.20251008013227.dist-info}/METADATA +1 -1
- {thds_core-1.45.20251007062722.dist-info → thds_core-1.46.20251008013227.dist-info}/RECORD +8 -8
- {thds_core-1.45.20251007062722.dist-info → thds_core-1.46.20251008013227.dist-info}/WHEEL +0 -0
- {thds_core-1.45.20251007062722.dist-info → thds_core-1.46.20251008013227.dist-info}/entry_points.txt +0 -0
- {thds_core-1.45.20251007062722.dist-info → thds_core-1.46.20251008013227.dist-info}/top_level.txt +0 -0
thds/core/sqlite/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from . import connect, copy, ddl, functions, index, read, sqlmap, upsert # noqa: F401
|
|
1
|
+
from . import connect, copy, ddl, functions, index, read, sqlmap, types, upsert # noqa: F401
|
|
2
2
|
from .merge import merge_databases # noqa: F401
|
|
3
3
|
from .meta import ( # noqa: F401
|
|
4
4
|
debug_errors,
|
thds/core/sqlite/meta.py
CHANGED
|
@@ -37,11 +37,50 @@ def list_tables(connectable: Connectable, schema_name: str = "") -> ty.List[str]
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
@autoconn_scope.bound
|
|
40
|
+
def get_sql_defs_by_name(
|
|
41
|
+
connectable: Connectable, types: ty.Collection[str], *, schema_name: str = "main"
|
|
42
|
+
) -> ty.Dict[str, str]:
|
|
43
|
+
conn = autoconnect(connectable)
|
|
44
|
+
return {
|
|
45
|
+
row[0]: row[1]
|
|
46
|
+
for row in conn.execute(
|
|
47
|
+
f"""
|
|
48
|
+
SELECT name, sql
|
|
49
|
+
FROM {fullname('sqlite_master', schema_name)}
|
|
50
|
+
WHERE type IN ({', '.join('?' for _ in types)})
|
|
51
|
+
AND sql is not null
|
|
52
|
+
""",
|
|
53
|
+
tuple(types),
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
40
58
|
def get_tables(connectable: Connectable, *, schema_name: str = "main") -> ty.Dict[str, str]:
|
|
41
59
|
"""Keys of the returned dict are the names of tables in the database.
|
|
42
60
|
|
|
43
61
|
Values of the returned dict are the raw SQL that can be used to recreate the table.
|
|
44
62
|
"""
|
|
63
|
+
return get_sql_defs_by_name(connectable, ["table"], schema_name=schema_name)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def get_views(connectable: Connectable, *, schema_name: str = "main") -> ty.Dict[str, str]:
|
|
67
|
+
"""Keys of the returned dict are the names of views in the database.
|
|
68
|
+
|
|
69
|
+
Values of the returned dict are the raw SQL that can be used to recreate the view.
|
|
70
|
+
"""
|
|
71
|
+
return get_sql_defs_by_name(connectable, ["view"], schema_name=schema_name)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def get_triggers(connectable: Connectable, *, schema_name: str = "main") -> dict[str, str]:
|
|
75
|
+
"""Keys of the returned dict are the names of triggers in the database.
|
|
76
|
+
Values of the returned dict are the raw SQL that can be used to recreate the trigger.
|
|
77
|
+
"""
|
|
78
|
+
return get_sql_defs_by_name(connectable, ["trigger"], schema_name=schema_name)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@autoconn_scope.bound
|
|
82
|
+
def get_virtual_tables(connectable: Connectable, *, schema_name: str = "main") -> dict[str, str]:
|
|
83
|
+
"""Get virtual tables (FTS, etc.)."""
|
|
45
84
|
conn = autoconnect(connectable)
|
|
46
85
|
return {
|
|
47
86
|
row[0]: row[1]
|
|
@@ -49,8 +88,7 @@ def get_tables(connectable: Connectable, *, schema_name: str = "main") -> ty.Dic
|
|
|
49
88
|
f"""
|
|
50
89
|
SELECT name, sql
|
|
51
90
|
FROM {fullname('sqlite_master', schema_name)}
|
|
52
|
-
WHERE type
|
|
53
|
-
AND sql is not null
|
|
91
|
+
WHERE type='table' AND sql LIKE 'CREATE VIRTUAL TABLE%'
|
|
54
92
|
"""
|
|
55
93
|
)
|
|
56
94
|
}
|
thds/core/sqlite/types.py
CHANGED
|
@@ -59,7 +59,7 @@ thds/core/source/_download.py,sha256=faKWxgzw1fTqOoyjtgi4IyhiZpBYTm_GZxwqC6LTiXU
|
|
|
59
59
|
thds/core/source/serde.py,sha256=zEAR24AewgDqqkIxcPpS7NZ-ZbEnQPK_A7siWlE3Q0E,3091
|
|
60
60
|
thds/core/source/src.py,sha256=nTUBgsAES0J73enIEbc5BitgnxA5kBnf88oYZoMQGnM,4596
|
|
61
61
|
thds/core/source/tree.py,sha256=iNCoCE655MwXQwc2Y0IIm1HMVk5Inj0NGVU9U8Wl_90,4317
|
|
62
|
-
thds/core/sqlite/__init__.py,sha256=
|
|
62
|
+
thds/core/sqlite/__init__.py,sha256=xJbwCoIeiOvsZDc2PlkJukRKmv3fIgSny68O6lulGPw,613
|
|
63
63
|
thds/core/sqlite/connect.py,sha256=l4QaSAI8RjP7Qh2FjmJ3EwRgfGf65Z3-LjtC9ocHM_U,977
|
|
64
64
|
thds/core/sqlite/copy.py,sha256=y3IRQTBrWDfKuVIfW7fYuEgwRCRKHjN0rxVFkIb9VrQ,1155
|
|
65
65
|
thds/core/sqlite/ddl.py,sha256=k9BvmDzb0rrlhmEpXkB6ESaZAUWtbL58x-70sPyoFk4,201
|
|
@@ -67,15 +67,15 @@ thds/core/sqlite/functions.py,sha256=AOIRzb7lNxmFm1J5JS6R8Nl-dSv3Dy47UNZVVjl1rvk
|
|
|
67
67
|
thds/core/sqlite/index.py,sha256=Vc7qxPqQ69A6GO5gmVQf5e3y8f8IqOTHgyEDoVZxTFM,903
|
|
68
68
|
thds/core/sqlite/insert_utils.py,sha256=BNI3VUdqwBdaqa0xqiJrhE6XyzPsTF8N4KKKdb4Vfes,884
|
|
69
69
|
thds/core/sqlite/merge.py,sha256=NxettDMJ_mcrWfteQn_ERY7MUB5ETR-yJLKg7uvF6zA,3779
|
|
70
|
-
thds/core/sqlite/meta.py,sha256=
|
|
70
|
+
thds/core/sqlite/meta.py,sha256=8Gh4FhTzU86FK8oWosoyPfT0EVd-kfieThEQBrD-l30,7299
|
|
71
71
|
thds/core/sqlite/read.py,sha256=5pWvrbed3XNWgSy-79-8ONWkkt4jWbTzFNW6SnOrdYQ,2576
|
|
72
72
|
thds/core/sqlite/sqlmap.py,sha256=LeyiJtY0ww_mbeSp7LQM-YuWnckulQqropxwAfkt5To,6818
|
|
73
73
|
thds/core/sqlite/structured.py,sha256=8t1B6XbM5NnudKEeBLsdjRVbSXXSr6iHOW0HwEAqtXU,4818
|
|
74
|
-
thds/core/sqlite/types.py,sha256=
|
|
74
|
+
thds/core/sqlite/types.py,sha256=oq8m0UrvSn1IqWWcQ4FPptfAhdj6DllnCe7puVqSHlY,1297
|
|
75
75
|
thds/core/sqlite/upsert.py,sha256=BmKK6fsGVedt43iY-Lp7dnAu8aJ1e9CYlPVEQR2pMj4,5827
|
|
76
76
|
thds/core/sqlite/write.py,sha256=z0219vDkQDCnsV0WLvsj94keItr7H4j7Y_evbcoBrWU,3458
|
|
77
|
-
thds_core-1.
|
|
78
|
-
thds_core-1.
|
|
79
|
-
thds_core-1.
|
|
80
|
-
thds_core-1.
|
|
81
|
-
thds_core-1.
|
|
77
|
+
thds_core-1.46.20251008013227.dist-info/METADATA,sha256=4q7nlyNrthr2-I0JqR4T0YLldKPouABTwC1NDWlAQyM,2216
|
|
78
|
+
thds_core-1.46.20251008013227.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
79
|
+
thds_core-1.46.20251008013227.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
|
|
80
|
+
thds_core-1.46.20251008013227.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
|
|
81
|
+
thds_core-1.46.20251008013227.dist-info/RECORD,,
|
|
File without changes
|
{thds_core-1.45.20251007062722.dist-info → thds_core-1.46.20251008013227.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{thds_core-1.45.20251007062722.dist-info → thds_core-1.46.20251008013227.dist-info}/top_level.txt
RENAMED
|
File without changes
|