FastSQLA 0.4.6__tar.gz → 0.5.1__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.
- {fastsqla-0.4.6 → fastsqla-0.5.1}/PKG-INFO +5 -5
- {fastsqla-0.4.6 → fastsqla-0.5.1}/pyproject.toml +29 -17
- {fastsqla-0.4.6 → fastsqla-0.5.1}/src/FastSQLA.egg-info/PKG-INFO +5 -5
- {fastsqla-0.4.6 → fastsqla-0.5.1}/src/FastSQLA.egg-info/requires.txt +4 -4
- {fastsqla-0.4.6 → fastsqla-0.5.1}/src/fastsqla.py +15 -5
- {fastsqla-0.4.6 → fastsqla-0.5.1}/README.md +0 -0
- {fastsqla-0.4.6 → fastsqla-0.5.1}/setup.cfg +0 -0
- {fastsqla-0.4.6 → fastsqla-0.5.1}/src/FastSQLA.egg-info/SOURCES.txt +0 -0
- {fastsqla-0.4.6 → fastsqla-0.5.1}/src/FastSQLA.egg-info/dependency_links.txt +0 -0
- {fastsqla-0.4.6 → fastsqla-0.5.1}/src/FastSQLA.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: FastSQLA
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: SQLAlchemy extension for FastAPI that supports asynchronous sessions and includes built-in pagination.
|
|
5
5
|
Author-email: Hadrien David <h@driendavid.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/hadrien/fastsqla
|
|
@@ -38,10 +38,10 @@ Requires-Dist: fastapi>=0.115.6
|
|
|
38
38
|
Requires-Dist: sqlalchemy[asyncio]>=2.0.37
|
|
39
39
|
Requires-Dist: structlog>=24.4.0
|
|
40
40
|
Provides-Extra: docs
|
|
41
|
-
Requires-Dist: mkdocs-glightbox>=0.
|
|
42
|
-
Requires-Dist: mkdocs-llmstxt>=0.
|
|
43
|
-
Requires-Dist: mkdocs-material>=9.
|
|
44
|
-
Requires-Dist: mkdocstrings[python]>=0.
|
|
41
|
+
Requires-Dist: mkdocs-glightbox>=0.5.2; extra == "docs"
|
|
42
|
+
Requires-Dist: mkdocs-llmstxt>=0.5.0; extra == "docs"
|
|
43
|
+
Requires-Dist: mkdocs-material>=9.7.1; extra == "docs"
|
|
44
|
+
Requires-Dist: mkdocstrings[python]>=1.0.0; extra == "docs"
|
|
45
45
|
Provides-Extra: sqlmodel
|
|
46
46
|
Requires-Dist: sqlmodel>=0.0.22; extra == "sqlmodel"
|
|
47
47
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "FastSQLA"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.5.1"
|
|
4
4
|
description = "SQLAlchemy extension for FastAPI that supports asynchronous sessions and includes built-in pagination."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -45,10 +45,10 @@ license-files = []
|
|
|
45
45
|
|
|
46
46
|
[project.optional-dependencies]
|
|
47
47
|
docs = [
|
|
48
|
-
"mkdocs-glightbox>=0.
|
|
49
|
-
"mkdocs-llmstxt>=0.
|
|
50
|
-
"mkdocs-material>=9.
|
|
51
|
-
"mkdocstrings[python]>=0.
|
|
48
|
+
"mkdocs-glightbox>=0.5.2",
|
|
49
|
+
"mkdocs-llmstxt>=0.5.0",
|
|
50
|
+
"mkdocs-material>=9.7.1",
|
|
51
|
+
"mkdocstrings[python]>=1.0.0",
|
|
52
52
|
]
|
|
53
53
|
sqlmodel = ["sqlmodel>=0.0.22"]
|
|
54
54
|
|
|
@@ -70,6 +70,7 @@ dev = [
|
|
|
70
70
|
"aiosqlite>=0.20.0",
|
|
71
71
|
"python-semantic-release>=9.8.8",
|
|
72
72
|
"twine>=5.1.1",
|
|
73
|
+
"pdbpp>=0.11.7",
|
|
73
74
|
]
|
|
74
75
|
|
|
75
76
|
[tool.uv.sources]
|
|
@@ -100,15 +101,26 @@ mode = "init"
|
|
|
100
101
|
changelog_file = "./docs/changelog.md"
|
|
101
102
|
|
|
102
103
|
[tool.tox]
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
[
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
envlist = ["sqlmodel", "fastapi-pre121", "fastapi-post121"]
|
|
105
|
+
|
|
106
|
+
[tool.tox.env_run_base]
|
|
107
|
+
runner = "uv-venv-runner"
|
|
108
|
+
commands = [
|
|
109
|
+
[
|
|
110
|
+
"pytest",
|
|
111
|
+
"--cov",
|
|
112
|
+
"fastsqla",
|
|
113
|
+
"--cov-report=term-missing",
|
|
114
|
+
"--cov-report=xml",
|
|
115
|
+
],
|
|
116
|
+
]
|
|
117
|
+
allowlist_externals = ["pytest", "pip"]
|
|
118
|
+
|
|
119
|
+
[tool.tox.env.sqlmodel]
|
|
120
|
+
extras = ["sqlmodel"]
|
|
121
|
+
|
|
122
|
+
[tool.tox.env.fastapi-pre121]
|
|
123
|
+
commands_pre = [["pip", "install", "-U", "fastapi<0.121"]]
|
|
124
|
+
|
|
125
|
+
[tool.tox.env.fastapi-post121]
|
|
126
|
+
commands_pre = [["pip", "install", "-U", "fastapi>=0.121"]]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: FastSQLA
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: SQLAlchemy extension for FastAPI that supports asynchronous sessions and includes built-in pagination.
|
|
5
5
|
Author-email: Hadrien David <h@driendavid.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/hadrien/fastsqla
|
|
@@ -38,10 +38,10 @@ Requires-Dist: fastapi>=0.115.6
|
|
|
38
38
|
Requires-Dist: sqlalchemy[asyncio]>=2.0.37
|
|
39
39
|
Requires-Dist: structlog>=24.4.0
|
|
40
40
|
Provides-Extra: docs
|
|
41
|
-
Requires-Dist: mkdocs-glightbox>=0.
|
|
42
|
-
Requires-Dist: mkdocs-llmstxt>=0.
|
|
43
|
-
Requires-Dist: mkdocs-material>=9.
|
|
44
|
-
Requires-Dist: mkdocstrings[python]>=0.
|
|
41
|
+
Requires-Dist: mkdocs-glightbox>=0.5.2; extra == "docs"
|
|
42
|
+
Requires-Dist: mkdocs-llmstxt>=0.5.0; extra == "docs"
|
|
43
|
+
Requires-Dist: mkdocs-material>=9.7.1; extra == "docs"
|
|
44
|
+
Requires-Dist: mkdocstrings[python]>=1.0.0; extra == "docs"
|
|
45
45
|
Provides-Extra: sqlmodel
|
|
46
46
|
Requires-Dist: sqlmodel>=0.0.22; extra == "sqlmodel"
|
|
47
47
|
|
|
@@ -3,10 +3,10 @@ sqlalchemy[asyncio]>=2.0.37
|
|
|
3
3
|
structlog>=24.4.0
|
|
4
4
|
|
|
5
5
|
[docs]
|
|
6
|
-
mkdocs-glightbox>=0.
|
|
7
|
-
mkdocs-llmstxt>=0.
|
|
8
|
-
mkdocs-material>=9.
|
|
9
|
-
mkdocstrings[python]>=0.
|
|
6
|
+
mkdocs-glightbox>=0.5.2
|
|
7
|
+
mkdocs-llmstxt>=0.5.0
|
|
8
|
+
mkdocs-material>=9.7.1
|
|
9
|
+
mkdocstrings[python]>=1.0.0
|
|
10
10
|
|
|
11
11
|
[sqlmodel]
|
|
12
12
|
sqlmodel>=0.0.22
|
|
@@ -2,9 +2,10 @@ import math
|
|
|
2
2
|
import os
|
|
3
3
|
from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable
|
|
4
4
|
from contextlib import _AsyncGeneratorContextManager, asynccontextmanager
|
|
5
|
-
from typing import Annotated, Generic,
|
|
5
|
+
from typing import Annotated, Generic, TypedDict, TypeVar
|
|
6
6
|
|
|
7
|
-
from fastapi import Depends
|
|
7
|
+
from fastapi import Depends as BaseDepends
|
|
8
|
+
from fastapi import FastAPI, Query
|
|
8
9
|
from pydantic import BaseModel, Field
|
|
9
10
|
from sqlalchemy import Result, Select, func, select
|
|
10
11
|
from sqlalchemy.ext.asyncio import (
|
|
@@ -44,6 +45,15 @@ SessionFactory = async_sessionmaker(expire_on_commit=False, class_=AsyncSession)
|
|
|
44
45
|
logger = get_logger(__name__)
|
|
45
46
|
|
|
46
47
|
|
|
48
|
+
def Depends(*args, **kwargs):
|
|
49
|
+
"Allow backward compatibility with fastapi<0.121"
|
|
50
|
+
try:
|
|
51
|
+
return BaseDepends(*args, **kwargs)
|
|
52
|
+
except TypeError:
|
|
53
|
+
kwargs.pop("scope")
|
|
54
|
+
return BaseDepends(*args, **kwargs)
|
|
55
|
+
|
|
56
|
+
|
|
47
57
|
class Base(DeclarativeBase, DeferredReflection):
|
|
48
58
|
"""Inherit from `Base` to declare an `SQLAlchemy` model.
|
|
49
59
|
|
|
@@ -80,7 +90,7 @@ class State(TypedDict):
|
|
|
80
90
|
|
|
81
91
|
def new_lifespan(
|
|
82
92
|
url: str | None = None, **kw
|
|
83
|
-
) -> Callable[[FastAPI], _AsyncGeneratorContextManager[State, None]]:
|
|
93
|
+
) -> Callable[[FastAPI | None], _AsyncGeneratorContextManager[State, None]]:
|
|
84
94
|
"""Create a new lifespan async context manager.
|
|
85
95
|
|
|
86
96
|
It expects the exact same parameters as
|
|
@@ -107,7 +117,7 @@ def new_lifespan(
|
|
|
107
117
|
has_config = url is not None
|
|
108
118
|
|
|
109
119
|
@asynccontextmanager
|
|
110
|
-
async def lifespan(app: FastAPI) -> AsyncGenerator[State, None]:
|
|
120
|
+
async def lifespan(app: FastAPI | None) -> AsyncGenerator[State, None]:
|
|
111
121
|
if has_config:
|
|
112
122
|
prefix = ""
|
|
113
123
|
sqla_config = {**kw, **{"url": url}}
|
|
@@ -252,7 +262,7 @@ async def new_session() -> AsyncGenerator[AsyncSession, None]:
|
|
|
252
262
|
yield session
|
|
253
263
|
|
|
254
264
|
|
|
255
|
-
Session = Annotated[AsyncSession, Depends(new_session)]
|
|
265
|
+
Session = Annotated[AsyncSession, Depends(new_session, scope="function")]
|
|
256
266
|
"""Dependency used exclusively in endpoints to get an `SQLAlchemy` or `SQLModel` session.
|
|
257
267
|
|
|
258
268
|
`Session` is a [`FastAPI` dependency](https://fastapi.tiangolo.com/tutorial/dependencies/)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|