python-glowplug 0.3.8__py3-none-any.whl → 0.3.10__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.
- glowplug/driver/base.py +5 -2
- glowplug/driver/mssql.py +18 -12
- glowplug/driver/pg.py +3 -1
- {python_glowplug-0.3.8.dist-info → python_glowplug-0.3.10.dist-info}/METADATA +1 -1
- python_glowplug-0.3.10.dist-info/RECORD +11 -0
- python_glowplug-0.3.8.dist-info/RECORD +0 -11
- {python_glowplug-0.3.8.dist-info → python_glowplug-0.3.10.dist-info}/LICENSE +0 -0
- {python_glowplug-0.3.8.dist-info → python_glowplug-0.3.10.dist-info}/WHEEL +0 -0
glowplug/driver/base.py
CHANGED
|
@@ -64,8 +64,11 @@ class DbDriver(ABC):
|
|
|
64
64
|
# Presumably this won't be run any context where that matters much,
|
|
65
65
|
# but ideally we'd have a way to do this async.
|
|
66
66
|
engine = self.get_sync_engine()
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
try:
|
|
68
|
+
inspector = inspect(engine)
|
|
69
|
+
return inspector.get_table_names()
|
|
70
|
+
finally:
|
|
71
|
+
engine.dispose()
|
|
69
72
|
|
|
70
73
|
async def is_blank_slate(self) -> bool:
|
|
71
74
|
"""Helper to check if the database is missing or has no tables.
|
glowplug/driver/mssql.py
CHANGED
|
@@ -27,14 +27,17 @@ class MsSqlDriver(DbDriver):
|
|
|
27
27
|
path, database = self._split_path()
|
|
28
28
|
# Connect to the database-less path
|
|
29
29
|
engine = create_async_engine(f"mssql+aioodbc://{path}")
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
try:
|
|
31
|
+
async with engine.connect() as conn:
|
|
32
|
+
# Check if the database exists
|
|
33
|
+
result = await conn.execute(
|
|
34
|
+
text("SELECT name FROM sys.databases WHERE name = :db"),
|
|
35
|
+
{"db": database},
|
|
36
|
+
)
|
|
37
|
+
row = result.fetchone()
|
|
38
|
+
return row is not None
|
|
39
|
+
finally:
|
|
40
|
+
await engine.dispose()
|
|
38
41
|
|
|
39
42
|
async def create(self) -> None:
|
|
40
43
|
"""Create the database."""
|
|
@@ -44,10 +47,13 @@ class MsSqlDriver(DbDriver):
|
|
|
44
47
|
engine = create_async_engine(f"mssql+aioodbc://{path}")
|
|
45
48
|
# Need to run this with autocommit=True to avoid a transaction error
|
|
46
49
|
# See: https://stackoverflow.com/a/42008664
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
try:
|
|
51
|
+
async with engine.connect() as conn:
|
|
52
|
+
rc = await conn.get_raw_connection()
|
|
53
|
+
rc.driver_connection.autocommit = True
|
|
54
|
+
await conn.execute(text(f"CREATE DATABASE {database}"))
|
|
55
|
+
finally:
|
|
56
|
+
await engine.dispose()
|
|
51
57
|
|
|
52
58
|
@property
|
|
53
59
|
def async_uri(self) -> str:
|
glowplug/driver/pg.py
CHANGED
|
@@ -50,7 +50,9 @@ class PostgresDriver(DbDriver):
|
|
|
50
50
|
if self.maintenance_db:
|
|
51
51
|
base_url = f"{base_url}/{self.maintenance_db}"
|
|
52
52
|
engine = create_async_engine(
|
|
53
|
-
f"postgresql+asyncpg://{base_url}",
|
|
53
|
+
f"postgresql+asyncpg://{base_url}",
|
|
54
|
+
echo=self.debug,
|
|
55
|
+
isolation_level="AUTOCOMMIT",
|
|
54
56
|
)
|
|
55
57
|
async with engine.connect() as conn:
|
|
56
58
|
await conn.execute(text(f"CREATE DATABASE {db_name}"))
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
glowplug/__init__.py,sha256=VKKI-9C6KSlXwvisxTQFhVUUtQdwiNeV_g8wB5TVjM4,378
|
|
2
|
+
glowplug/config/__init__.py,sha256=0v2Tqk8mJ3v_wRuifXP1-V4x7--xupBxxtrSt2CFqXs,1628
|
|
3
|
+
glowplug/driver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
glowplug/driver/base.py,sha256=_6nB66LbJa2E_DHbrOueUfT7CHtKiRccOQBIx-Ii43k,4174
|
|
5
|
+
glowplug/driver/mssql.py,sha256=e_0XuDRYSd-MwEtdjc4CM2dcnQC7mLw1jK-6G7K6__I,2813
|
|
6
|
+
glowplug/driver/pg.py,sha256=nBjo4gjjIuGtkPGMSrdq4essX19pyQeIXs6SlADVNm8,2661
|
|
7
|
+
glowplug/driver/sqlite.py,sha256=SPhZXYMu_OcdN2r7dr5YJA-3Jsd-deH7peMWYEzX_sE,1070
|
|
8
|
+
python_glowplug-0.3.10.dist-info/LICENSE,sha256=HvAzro26TfbigQ3ppmyagEGHIr_UtyQDfU8muTAqWFU,1060
|
|
9
|
+
python_glowplug-0.3.10.dist-info/METADATA,sha256=HcIs0n3AH2eXIqNmwm9evdXb0_G4wbDUjjLgC8l5Iwg,1495
|
|
10
|
+
python_glowplug-0.3.10.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
11
|
+
python_glowplug-0.3.10.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
glowplug/__init__.py,sha256=VKKI-9C6KSlXwvisxTQFhVUUtQdwiNeV_g8wB5TVjM4,378
|
|
2
|
-
glowplug/config/__init__.py,sha256=0v2Tqk8mJ3v_wRuifXP1-V4x7--xupBxxtrSt2CFqXs,1628
|
|
3
|
-
glowplug/driver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
glowplug/driver/base.py,sha256=IsltopDs-nl4JQsa5kPaegR1UEzOZAnLbGuOeGD7W7I,4107
|
|
5
|
-
glowplug/driver/mssql.py,sha256=gbrlh2O-LViDwNmwwpme0sNzu2EbgJtQKbp4o_mNrvs,2635
|
|
6
|
-
glowplug/driver/pg.py,sha256=CMp-dKpBNjnYSmXh_HOVJZbHlgt2CwaQ-8ALMTGA1AM,2606
|
|
7
|
-
glowplug/driver/sqlite.py,sha256=SPhZXYMu_OcdN2r7dr5YJA-3Jsd-deH7peMWYEzX_sE,1070
|
|
8
|
-
python_glowplug-0.3.8.dist-info/LICENSE,sha256=HvAzro26TfbigQ3ppmyagEGHIr_UtyQDfU8muTAqWFU,1060
|
|
9
|
-
python_glowplug-0.3.8.dist-info/METADATA,sha256=NxOQtWq8rEysPvCYJ2BEEQnDt00qmKrvV0otUbkTWzM,1494
|
|
10
|
-
python_glowplug-0.3.8.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
11
|
-
python_glowplug-0.3.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|