dycw-utilities 0.153.7__py3-none-any.whl → 0.153.8__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.
- {dycw_utilities-0.153.7.dist-info → dycw_utilities-0.153.8.dist-info}/METADATA +1 -1
- {dycw_utilities-0.153.7.dist-info → dycw_utilities-0.153.8.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/sqlalchemy.py +25 -3
- {dycw_utilities-0.153.7.dist-info → dycw_utilities-0.153.8.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.153.7.dist-info → dycw_utilities-0.153.8.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.153.7.dist-info → dycw_utilities-0.153.8.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=fSwBHH_QjQiuW9YKDHQhOfKP46dlOwjxz1pfnRc0A_w,60
|
2
2
|
utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
|
3
3
|
utilities/asyncio.py,sha256=QXkTtugXkqtYt7Do23zgYErqzdp6jwzPpV_SP9fJ1gI,16780
|
4
4
|
utilities/atomicwrites.py,sha256=tPo6r-Rypd9u99u66B9z86YBPpnLrlHtwox_8Z7T34Y,5790
|
@@ -64,7 +64,7 @@ utilities/sentinel.py,sha256=3jIwgpMekWgDAxPDA_hXMP2St43cPhciKN3LWiZ7kv0,1248
|
|
64
64
|
utilities/shelve.py,sha256=4OzjQI6kGuUbJciqf535rwnao-_IBv66gsT6tRGiUt0,759
|
65
65
|
utilities/slack_sdk.py,sha256=ppFBvKgfg5IRWiIoKPtpTyzBtBF4XmwEvU3I5wLJikM,2140
|
66
66
|
utilities/socket.py,sha256=K77vfREvzoVTrpYKo6MZakol0EYu2q1sWJnnZqL0So0,118
|
67
|
-
utilities/sqlalchemy.py,sha256=
|
67
|
+
utilities/sqlalchemy.py,sha256=bSwgIOd09Pmd7D39Rv2gl6t9qHz1iYQIrPnyDUWz7pc,40411
|
68
68
|
utilities/sqlalchemy_polars.py,sha256=Mm-sShZfqqgnzTrupMQdCfSM2akrybXHXAErTs-ofM8,14244
|
69
69
|
utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
|
70
70
|
utilities/string.py,sha256=shmBK87zZwzGyixuNuXCiUbqzfeZ9xlrFwz6JTaRvDk,582
|
@@ -87,8 +87,8 @@ utilities/zoneinfo.py,sha256=FBMcUQ4662Aq8SsuCL1OAhDQiyANmVjtb-C30DRrWoE,1966
|
|
87
87
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
88
88
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
89
89
|
utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
|
90
|
-
dycw_utilities-0.153.
|
91
|
-
dycw_utilities-0.153.
|
92
|
-
dycw_utilities-0.153.
|
93
|
-
dycw_utilities-0.153.
|
94
|
-
dycw_utilities-0.153.
|
90
|
+
dycw_utilities-0.153.8.dist-info/METADATA,sha256=kGabwftmrxbs70yKIeBiQDg0K-kZZwemtsaDauXny18,1696
|
91
|
+
dycw_utilities-0.153.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
92
|
+
dycw_utilities-0.153.8.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
93
|
+
dycw_utilities-0.153.8.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
94
|
+
dycw_utilities-0.153.8.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/sqlalchemy.py
CHANGED
@@ -30,7 +30,6 @@ from typing import (
|
|
30
30
|
)
|
31
31
|
|
32
32
|
import sqlalchemy
|
33
|
-
import sqlalchemy.ext.asyncio
|
34
33
|
from sqlalchemy import (
|
35
34
|
URL,
|
36
35
|
Column,
|
@@ -63,7 +62,7 @@ from sqlalchemy.exc import (
|
|
63
62
|
OperationalError,
|
64
63
|
ProgrammingError,
|
65
64
|
)
|
66
|
-
from sqlalchemy.ext.asyncio import AsyncConnection, AsyncEngine
|
65
|
+
from sqlalchemy.ext.asyncio import AsyncConnection, AsyncEngine, create_async_engine
|
67
66
|
from sqlalchemy.orm import (
|
68
67
|
DeclarativeBase,
|
69
68
|
InstrumentedAttribute,
|
@@ -311,7 +310,7 @@ def create_engine(
|
|
311
310
|
case False:
|
312
311
|
return sqlalchemy.create_engine(url, poolclass=poolclass)
|
313
312
|
case True:
|
314
|
-
return
|
313
|
+
return create_async_engine(url, poolclass=poolclass)
|
315
314
|
case never:
|
316
315
|
assert_never(never)
|
317
316
|
|
@@ -319,6 +318,27 @@ def create_engine(
|
|
319
318
|
##
|
320
319
|
|
321
320
|
|
321
|
+
async def ensure_database_created(super_: URL, database: str, /) -> None:
|
322
|
+
"""Ensure a database is created."""
|
323
|
+
engine = create_async_engine(super_, isolation_level="AUTOCOMMIT")
|
324
|
+
async with engine.begin() as conn:
|
325
|
+
try:
|
326
|
+
_ = await conn.execute(text(f"CREATE DATABASE {database}"))
|
327
|
+
except (OperationalError, ProgrammingError) as error:
|
328
|
+
if not search('database ".*" already exists', ensure_str(one(error.args))):
|
329
|
+
raise
|
330
|
+
|
331
|
+
|
332
|
+
async def ensure_database_dropped(super_: URL, database: str, /) -> None:
|
333
|
+
"""Ensure a database is dropped."""
|
334
|
+
engine = create_async_engine(super_, isolation_level="AUTOCOMMIT")
|
335
|
+
async with engine.begin() as conn:
|
336
|
+
_ = await conn.execute(text(f"DROP DATABASE IF EXISTS {database}"))
|
337
|
+
|
338
|
+
|
339
|
+
##
|
340
|
+
|
341
|
+
|
322
342
|
async def ensure_tables_created(
|
323
343
|
engine: AsyncEngine,
|
324
344
|
/,
|
@@ -1284,6 +1304,8 @@ __all__ = [
|
|
1284
1304
|
"columnwise_max",
|
1285
1305
|
"columnwise_min",
|
1286
1306
|
"create_engine",
|
1307
|
+
"ensure_database_created",
|
1308
|
+
"ensure_database_dropped",
|
1287
1309
|
"ensure_tables_created",
|
1288
1310
|
"ensure_tables_dropped",
|
1289
1311
|
"enum_name",
|
File without changes
|
File without changes
|
File without changes
|