python-glowplug 0.3.11__py3-none-any.whl → 0.3.13__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/config/__init__.py +3 -3
- glowplug/driver/pg.py +17 -1
- {python_glowplug-0.3.11.dist-info → python_glowplug-0.3.13.dist-info}/METADATA +12 -13
- python_glowplug-0.3.13.dist-info/RECORD +11 -0
- {python_glowplug-0.3.11.dist-info → python_glowplug-0.3.13.dist-info}/WHEEL +1 -1
- python_glowplug-0.3.11.dist-info/RECORD +0 -11
- {python_glowplug-0.3.11.dist-info → python_glowplug-0.3.13.dist-info/licenses}/LICENSE +0 -0
glowplug/config/__init__.py
CHANGED
|
@@ -11,7 +11,7 @@ from ..driver.sqlite import SqliteDriver
|
|
|
11
11
|
class SqliteSettings(BaseModel):
|
|
12
12
|
"""Settings for connecting to SQLite."""
|
|
13
13
|
|
|
14
|
-
engine: Literal["sqlite"]
|
|
14
|
+
engine: Literal["sqlite"] = "sqlite"
|
|
15
15
|
path: str = ":memory:"
|
|
16
16
|
|
|
17
17
|
@cached_property
|
|
@@ -25,7 +25,7 @@ PgSslMode = Literal["disable", "allow", "prefer", "require", "verify-ca", "verif
|
|
|
25
25
|
class PostgresSettings(BaseModel):
|
|
26
26
|
"""Settings for connecting to Postgres."""
|
|
27
27
|
|
|
28
|
-
engine: Literal["postgres"]
|
|
28
|
+
engine: Literal["postgres"] = "postgres"
|
|
29
29
|
host: str = "localhost"
|
|
30
30
|
port: int = 5432
|
|
31
31
|
user: str = "postgres"
|
|
@@ -47,7 +47,7 @@ class PostgresSettings(BaseModel):
|
|
|
47
47
|
class MsSqlSettings(BaseModel):
|
|
48
48
|
"""Settings for connecting to Microsoft SQL Server."""
|
|
49
49
|
|
|
50
|
-
engine: Literal["mssql"]
|
|
50
|
+
engine: Literal["mssql"] = "mssql"
|
|
51
51
|
odbc_driver: Literal["ODBC Driver 17 for SQL Server"] = (
|
|
52
52
|
"ODBC Driver 17 for SQL Server"
|
|
53
53
|
)
|
glowplug/driver/pg.py
CHANGED
|
@@ -23,11 +23,24 @@ class PostgresDriver(DbDriver):
|
|
|
23
23
|
self.url = url
|
|
24
24
|
self.maintenance_db = maintenance_db
|
|
25
25
|
|
|
26
|
+
@classmethod
|
|
27
|
+
def _fix_query_for_asyncpg(cls, query: str) -> str:
|
|
28
|
+
"""Fix the query string for asyncpg.
|
|
29
|
+
|
|
30
|
+
asyncpg uses "ssl" instead of "sslmode" for the query param.
|
|
31
|
+
|
|
32
|
+
See: https://github.com/MagicStack/asyncpg/issues/737
|
|
33
|
+
|
|
34
|
+
Need to call this method in any async context, sadly.
|
|
35
|
+
"""
|
|
36
|
+
return query.replace("sslmode", "ssl")
|
|
37
|
+
|
|
26
38
|
async def exists(self) -> bool:
|
|
27
39
|
"""Check if the database exists."""
|
|
28
40
|
# Split the url on the last / to get base url & db name
|
|
29
41
|
base_url, db_name, query = self._split_url()
|
|
30
42
|
# If a maintenance db is provided, use that to check if the db exists
|
|
43
|
+
query = self._fix_query_for_asyncpg(query)
|
|
31
44
|
if self.maintenance_db:
|
|
32
45
|
base_url = f"{base_url}/{self.maintenance_db}?{query}"
|
|
33
46
|
engine = create_async_engine(
|
|
@@ -47,6 +60,7 @@ class PostgresDriver(DbDriver):
|
|
|
47
60
|
"""Create the database."""
|
|
48
61
|
base_url, db_name, query = self._split_url()
|
|
49
62
|
# If a maintenance db is provided, use that to create the db
|
|
63
|
+
query = self._fix_query_for_asyncpg(query)
|
|
50
64
|
if self.maintenance_db:
|
|
51
65
|
base_url = f"{base_url}/{self.maintenance_db}?{query}"
|
|
52
66
|
engine = create_async_engine(
|
|
@@ -61,7 +75,9 @@ class PostgresDriver(DbDriver):
|
|
|
61
75
|
@property
|
|
62
76
|
def async_uri(self) -> str:
|
|
63
77
|
"""Async connection string."""
|
|
64
|
-
|
|
78
|
+
url, db, query = self._split_url()
|
|
79
|
+
query = self._fix_query_for_asyncpg(query)
|
|
80
|
+
return f"postgresql+asyncpg://{url}/{db}?{query}"
|
|
65
81
|
|
|
66
82
|
@property
|
|
67
83
|
def sync_uri(self) -> str:
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: python-glowplug
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.13
|
|
4
4
|
Summary: A collection of utilities for common DB maintenance operations in SQLAlchemy
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Requires-Python: >=3.9,<4.0
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
5
|
+
Project-URL: Repository, https://github.com/jnu/python-glowplug
|
|
6
|
+
Author-email: Joe Nudell <jnudell@hks.harvard.edu>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
11
9
|
Classifier: Programming Language :: Python :: 3
|
|
12
10
|
Classifier: Programming Language :: Python :: 3.9
|
|
13
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Requires-
|
|
19
|
-
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Requires-Python: <4,>=3.9
|
|
17
|
+
Requires-Dist: alembic<2,>=1.5
|
|
18
|
+
Requires-Dist: pydantic<3,>=2
|
|
19
|
+
Requires-Dist: sqlalchemy<3,>=2
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
|
|
22
22
|
Glowplug
|
|
@@ -40,4 +40,3 @@ Chooses opinionated drivers with both async + sync support, as well as support f
|
|
|
40
40
|
- SQLite (`aiosqlite`)
|
|
41
41
|
- Postgres (`asyncpg`)
|
|
42
42
|
- MS Sql (`pyodbc` and `aioodbc`)
|
|
43
|
-
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
glowplug/__init__.py,sha256=VKKI-9C6KSlXwvisxTQFhVUUtQdwiNeV_g8wB5TVjM4,378
|
|
2
|
+
glowplug/config/__init__.py,sha256=DlZhXRYKjMZjyJiBcw2nv70BDiWVMmCEN8qacB7GRow,1863
|
|
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=0M15-ckuQCRVe26nRBw3gmM8FwpqlVkpYH8PgpgJr1E,3341
|
|
7
|
+
glowplug/driver/sqlite.py,sha256=SPhZXYMu_OcdN2r7dr5YJA-3Jsd-deH7peMWYEzX_sE,1070
|
|
8
|
+
python_glowplug-0.3.13.dist-info/METADATA,sha256=GSH2-vaclpQVbEqHTDsI3TTfQDCbJ77HSgHdnHzspiw,1509
|
|
9
|
+
python_glowplug-0.3.13.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
10
|
+
python_glowplug-0.3.13.dist-info/licenses/LICENSE,sha256=HvAzro26TfbigQ3ppmyagEGHIr_UtyQDfU8muTAqWFU,1060
|
|
11
|
+
python_glowplug-0.3.13.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
glowplug/__init__.py,sha256=VKKI-9C6KSlXwvisxTQFhVUUtQdwiNeV_g8wB5TVjM4,378
|
|
2
|
-
glowplug/config/__init__.py,sha256=F2Yzq49b08b_rcCP0TKBYPPF5TVEM5udTP3IGPIu4yk,1829
|
|
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=Rhe1N9htlao1hawektRirt5glmc46WBBa4Ng0s8kcEs,2763
|
|
7
|
-
glowplug/driver/sqlite.py,sha256=SPhZXYMu_OcdN2r7dr5YJA-3Jsd-deH7peMWYEzX_sE,1070
|
|
8
|
-
python_glowplug-0.3.11.dist-info/LICENSE,sha256=HvAzro26TfbigQ3ppmyagEGHIr_UtyQDfU8muTAqWFU,1060
|
|
9
|
-
python_glowplug-0.3.11.dist-info/METADATA,sha256=WPk39RAxAFoBdMH4cgHmT--BLZbM6jGzIOsZS_7COEw,1495
|
|
10
|
-
python_glowplug-0.3.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
11
|
-
python_glowplug-0.3.11.dist-info/RECORD,,
|
|
File without changes
|