python-glowplug 0.3.11__tar.gz → 0.3.13__tar.gz

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.
@@ -0,0 +1,162 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
@@ -1,22 +1,22 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.5
2
2
  Name: python-glowplug
3
- Version: 0.3.11
3
+ Version: 0.3.13
4
4
  Summary: A collection of utilities for common DB maintenance operations in SQLAlchemy
5
- Home-page: https://github.com/jnu/python-glowplug
6
- License: MIT
7
- Author: Joe Nudell
8
- Author-email: jnudell@hks.harvard.edu
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
- Requires-Dist: alembic (>=1.5,<2.0)
17
- Requires-Dist: pydantic (>=2,<3)
18
- Requires-Dist: sqlalchemy (>=2,<3)
19
- Project-URL: Repository, https://github.com/jnu/python-glowplug
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,44 @@
1
+ [project]
2
+ name = "python-glowplug"
3
+ version = "0.3.13"
4
+ description = "A collection of utilities for common DB maintenance operations in SQLAlchemy"
5
+ authors = [{ name = "Joe Nudell", email = "jnudell@hks.harvard.edu" }]
6
+ requires-python = ">=3.9,<4"
7
+ readme = "README.md"
8
+ license = "MIT"
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "Programming Language :: Python :: 3.9",
12
+ "Programming Language :: Python :: 3.10",
13
+ "Programming Language :: Python :: 3.11",
14
+ "Programming Language :: Python :: 3.12",
15
+ "Programming Language :: Python :: 3.13",
16
+ "Programming Language :: Python :: 3.14",
17
+ ]
18
+ dependencies = [
19
+ "sqlalchemy>=2,<3",
20
+ "alembic>=1.5,<2",
21
+ "pydantic>=2,<3",
22
+ ]
23
+
24
+ [project.urls]
25
+ Repository = "https://github.com/jnu/python-glowplug"
26
+
27
+ [dependency-groups]
28
+ dev = ["pre-commit>=3.7.0,<4"]
29
+
30
+ [tool.uv]
31
+ default-groups = "all"
32
+
33
+ [tool.hatch.build.targets.sdist]
34
+ include = ["src/glowplug"]
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ include = ["src/glowplug"]
38
+
39
+ [tool.hatch.build.targets.wheel.sources]
40
+ "src/glowplug" = "glowplug"
41
+
42
+ [build-system]
43
+ requires = ["hatchling"]
44
+ build-backend = "hatchling.build"
@@ -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
  )
@@ -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
- return f"postgresql+asyncpg://{self.url}"
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,25 +0,0 @@
1
- [tool.poetry]
2
- name = "python-glowplug"
3
- version = "0.3.11"
4
- description = "A collection of utilities for common DB maintenance operations in SQLAlchemy"
5
- authors = ["Joe Nudell <jnudell@hks.harvard.edu>"]
6
- readme = "README.md"
7
- license = "MIT"
8
- repository = "https://github.com/jnu/python-glowplug"
9
- packages = [
10
- { include = "glowplug", from = "src" }
11
- ]
12
-
13
- [tool.poetry.dependencies]
14
- python = "^3.9"
15
- sqlalchemy = "^2"
16
- alembic = "^1.5"
17
- pydantic = "^2"
18
-
19
-
20
- [tool.poetry.group.dev.dependencies]
21
- pre-commit = "^3.7.0"
22
-
23
- [build-system]
24
- requires = ["poetry-core"]
25
- build-backend = "poetry.core.masonry.api"