dycw-utilities 0.167.0__py3-none-any.whl → 0.167.1__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 dycw-utilities might be problematic. Click here for more details.
- {dycw_utilities-0.167.0.dist-info → dycw_utilities-0.167.1.dist-info}/METADATA +1 -1
- {dycw_utilities-0.167.0.dist-info → dycw_utilities-0.167.1.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/sqlalchemy.py +15 -0
- {dycw_utilities-0.167.0.dist-info → dycw_utilities-0.167.1.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.167.0.dist-info → dycw_utilities-0.167.1.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.167.0.dist-info → dycw_utilities-0.167.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
utilities/__init__.py,sha256=
|
|
1
|
+
utilities/__init__.py,sha256=5n59LyIEvqGZR7Atiaj1WopkM0tKCDhQyUb2l-MH_qc,60
|
|
2
2
|
utilities/aeventkit.py,sha256=ddoleSwW9zdc2tjX5Ge0pMKtYwV_JMxhHYOxnWX2AGM,12609
|
|
3
3
|
utilities/altair.py,sha256=nHdpWt8ZwdUwRQN970MvHd5bRWokNqzHcZQEdSHKRuE,9033
|
|
4
4
|
utilities/asyncio.py,sha256=60l1IwjnRGeaVphAFiwDIHyfKoZYKY-XGpptUxGiU-M,17034
|
|
@@ -69,7 +69,7 @@ utilities/sentinel.py,sha256=A_p5jX2K0Yc5XBfoYHyBLqHsEWzE1ByOdDuzzA2pZnE,1434
|
|
|
69
69
|
utilities/shelve.py,sha256=4OzjQI6kGuUbJciqf535rwnao-_IBv66gsT6tRGiUt0,759
|
|
70
70
|
utilities/slack_sdk.py,sha256=76-DYtcGiUhEvl-voMamc5OjfF7Y7nCq54Bys1arqzw,2233
|
|
71
71
|
utilities/socket.py,sha256=K77vfREvzoVTrpYKo6MZakol0EYu2q1sWJnnZqL0So0,118
|
|
72
|
-
utilities/sqlalchemy.py,sha256=
|
|
72
|
+
utilities/sqlalchemy.py,sha256=HQYpd7LFxdTF5WYVWYtCJeEBI71EJm7ytvCGyAH9B-U,37163
|
|
73
73
|
utilities/sqlalchemy_polars.py,sha256=JCGhB37raSR7fqeWV5dTsciRTMVzIdVT9YSqKT0piT0,13370
|
|
74
74
|
utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
|
|
75
75
|
utilities/string.py,sha256=shmBK87zZwzGyixuNuXCiUbqzfeZ9xlrFwz6JTaRvDk,582
|
|
@@ -93,8 +93,8 @@ utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
|
|
|
93
93
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
|
94
94
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
|
95
95
|
utilities/pytest_plugins/pytest_regressions.py,sha256=mnHYBfdprz50UGVkVzV1bZERZN5CFfoF8YbokGxdFwU,1639
|
|
96
|
-
dycw_utilities-0.167.
|
|
97
|
-
dycw_utilities-0.167.
|
|
98
|
-
dycw_utilities-0.167.
|
|
99
|
-
dycw_utilities-0.167.
|
|
100
|
-
dycw_utilities-0.167.
|
|
96
|
+
dycw_utilities-0.167.1.dist-info/METADATA,sha256=YDvpCOu6_rWr8_UnnjOzy0UM4JQABa4nltfz7kkNkLU,1698
|
|
97
|
+
dycw_utilities-0.167.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
98
|
+
dycw_utilities-0.167.1.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
|
99
|
+
dycw_utilities-0.167.1.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
|
100
|
+
dycw_utilities-0.167.1.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/sqlalchemy.py
CHANGED
|
@@ -331,6 +331,20 @@ async def ensure_database_dropped(super_: URL, database: str, /) -> None:
|
|
|
331
331
|
_ = await conn.execute(text(f"DROP DATABASE IF EXISTS {database}"))
|
|
332
332
|
|
|
333
333
|
|
|
334
|
+
async def ensure_database_users_disconnected(super_: URL, database: str, /) -> None:
|
|
335
|
+
"""Ensure a databases' users are disconnected."""
|
|
336
|
+
engine = create_async_engine(super_, isolation_level="AUTOCOMMIT")
|
|
337
|
+
match dialect := _get_dialect(engine):
|
|
338
|
+
case "postgresql": # skipif-ci-and-not-linux
|
|
339
|
+
query = f"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = {database!r} AND pid <> pg_backend_pid()" # noqa: S608
|
|
340
|
+
case "mssql" | "mysql" | "oracle" | "sqlite": # pragma: no cover
|
|
341
|
+
raise NotImplementedError(dialect)
|
|
342
|
+
case never:
|
|
343
|
+
assert_never(never)
|
|
344
|
+
async with engine.begin() as conn:
|
|
345
|
+
_ = await conn.execute(text(query))
|
|
346
|
+
|
|
347
|
+
|
|
334
348
|
##
|
|
335
349
|
|
|
336
350
|
|
|
@@ -1166,6 +1180,7 @@ __all__ = [
|
|
|
1166
1180
|
"create_engine",
|
|
1167
1181
|
"ensure_database_created",
|
|
1168
1182
|
"ensure_database_dropped",
|
|
1183
|
+
"ensure_database_users_disconnected",
|
|
1169
1184
|
"ensure_tables_created",
|
|
1170
1185
|
"ensure_tables_dropped",
|
|
1171
1186
|
"enum_name",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|