thds.core 1.45.20251006224153__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/parallel.py CHANGED
@@ -85,6 +85,10 @@ def yield_all(
85
85
  same size as your iterable. If you want to throttle the number of
86
86
  parallel tasks, you should provide your own Executor - and for
87
87
  most mops purposes it should be a ThreadPoolExecutor.
88
+
89
+ Currently this function does not yield any results until the input iterable is exhausted,
90
+ even though some of the thunks may have been submitted and the workers have returned a result
91
+ to the local process.
88
92
  """
89
93
  files.bump_limits()
90
94
  len_or_none = try_len(thunks)
@@ -107,6 +111,9 @@ def yield_all(
107
111
  with executor_cm as executor:
108
112
  keys_onto_futures = {key: executor.submit(thunk) for key, thunk in thunks}
109
113
  future_ids_onto_keys = {id(future): key for key, future in keys_onto_futures.items()}
114
+ # While concurrent.futures.as_completed accepts an iterable as input, it
115
+ # does not yield any completed futures until the input iterable is
116
+ # exhausted.
110
117
  for i, future in enumerate(concurrent.futures.as_completed(keys_onto_futures.values()), start=1):
111
118
  thunk_key = future_ids_onto_keys[id(future)]
112
119
  try:
@@ -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 = 'table'
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,4 +59,4 @@ def maybe_t(
59
59
  return None
60
60
 
61
61
 
62
- Connectable = ty.Union[os.PathLike, sqlite3.Connection]
62
+ Connectable = ty.Union[str, os.PathLike, sqlite3.Connection]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thds.core
3
- Version: 1.45.20251006224153
3
+ Version: 1.46.20251008013227
4
4
  Summary: Core utilities.
5
5
  Author-email: Trilliant Health <info@trillianthealth.com>
6
6
  License: MIT
@@ -29,7 +29,7 @@ thds/core/link.py,sha256=4-9d22l_oSkKoSzlYEO-rwxO1hvvj6VETY7LwvGcX6M,5534
29
29
  thds/core/logical_root.py,sha256=gWkIYRv9kNQfzbpxJaYiwNXVz1neZ2NvnvProtOn9d8,1399
30
30
  thds/core/merge_args.py,sha256=7oj7dtO1-XVkfTM3aBlq3QlZbo8tb6X7E3EVIR-60t8,5781
31
31
  thds/core/meta.py,sha256=Df0DxV5UzHcEsu5UCYaE1BWipMPTEXycn9Ug4cdquMk,12114
32
- thds/core/parallel.py,sha256=uYVmdYvD0v3RrQq6YY1o7qPY3KQIPPdzyxZMnFr2DzU,8139
32
+ thds/core/parallel.py,sha256=wRN0rZ8OebRYHkQT-1De5MbhCqdm2H0GJmWEjo_ylKI,8535
33
33
  thds/core/pickle_visit.py,sha256=QNMWIi5buvk2zsvx1-D-FKL7tkrFUFDs387vxgGebgU,833
34
34
  thds/core/prof.py,sha256=5ViolfPsAPwUTHuhAe-bon7IArPGXydpGoB5uZmObDk,8264
35
35
  thds/core/progress.py,sha256=tY8tc_6CMnu_O8DVisnsRoDpFJOw5vqyYzLhQDxsLn8,4361
@@ -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=tDMzuO76qTtckJHldPQ6nPZ6kcvhhoJrVuuW42JtaSQ,606
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=4P65PAmCjagHYO1Z6nWM-wkjEWv3hxw5qVa4cIpcH_8,5859
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=Zb1FtSAmC1L7QPPCV1eRnWpJuF74t9R293ai1SHtdS4,1292
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.45.20251006224153.dist-info/METADATA,sha256=oLBnz6nZwGiCLex27jUOPleeLERCjLOwkXR_n-uEd0k,2216
78
- thds_core-1.45.20251006224153.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
79
- thds_core-1.45.20251006224153.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
80
- thds_core-1.45.20251006224153.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
81
- thds_core-1.45.20251006224153.dist-info/RECORD,,
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,,