poetry add 'fastapi-users[sqlalchemy]'
This commit is contained in:
parent
8ec2ed1ebd
commit
541e35bc51
|
@ -1,3 +1,5 @@
|
|||
from typing import ClassVar
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic_settings import (
|
||||
BaseSettings,
|
||||
|
@ -45,6 +47,10 @@ class DatabaseConfig(BaseModel):
|
|||
}
|
||||
|
||||
|
||||
class TypesConfig(BaseModel):
|
||||
UserIdType: ClassVar = int
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=(
|
||||
|
@ -58,6 +64,7 @@ class Settings(BaseSettings):
|
|||
run: RunConfig
|
||||
swagger: SwaggerConfig = SwaggerConfig()
|
||||
db: DatabaseConfig
|
||||
type: TypesConfig = TypesConfig()
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from .db_helper import db_helper
|
||||
from .base import Base
|
||||
|
||||
from .user import User
|
||||
|
||||
|
||||
__all__ = (
|
||||
"db_helper",
|
||||
"Base",
|
||||
"User",
|
||||
)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
from .id_int_pk import IdIntPkMixin
|
||||
|
||||
|
||||
__all__ = ("IdIntPkMixin",)
|
|
@ -0,0 +1,19 @@
|
|||
from config import settings
|
||||
from models import Base
|
||||
from models.mixins import IdIntPkMixin
|
||||
|
||||
from fastapi_users_db_sqlalchemy import (
|
||||
SQLAlchemyBaseUserTable,
|
||||
SQLAlchemyUserDatabase,
|
||||
)
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
|
||||
class User(Base, IdIntPkMixin, SQLAlchemyBaseUserTable[settings.types.UserIdType]):
|
||||
|
||||
@classmethod
|
||||
def get_db(cls, session: "AsyncSession"):
|
||||
return SQLAlchemyUserDatabase(session, cls)
|
|
@ -467,6 +467,7 @@ files = [
|
|||
[package.dependencies]
|
||||
email-validator = ">=1.1.0,<2.2"
|
||||
fastapi = ">=0.65.2"
|
||||
fastapi-users-db-sqlalchemy = {version = ">=6.0.0", optional = true, markers = "extra == \"sqlalchemy\""}
|
||||
makefun = ">=1.11.2,<2.0.0"
|
||||
pwdlib = {version = "0.2.0", extras = ["argon2", "bcrypt"]}
|
||||
pyjwt = {version = "2.8.0", extras = ["crypto"]}
|
||||
|
@ -478,6 +479,21 @@ oauth = ["httpx-oauth (>=0.13)"]
|
|||
redis = ["redis (>=4.3.3,<6.0.0)"]
|
||||
sqlalchemy = ["fastapi-users-db-sqlalchemy (>=6.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "fastapi-users-db-sqlalchemy"
|
||||
version = "6.0.1"
|
||||
description = "FastAPI Users database adapter for SQLAlchemy"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "fastapi_users_db_sqlalchemy-6.0.1-py3-none-any.whl", hash = "sha256:d1050ec31eb75e8c4fa9abafa4addaf0baf5c97afeea2f0f910ea55e2451fcad"},
|
||||
{file = "fastapi_users_db_sqlalchemy-6.0.1.tar.gz", hash = "sha256:f0ef9fe3250453712d25c13170700c80fa205867ce7add7ef391c384ec27cbe1"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
fastapi-users = ">=10.0.0"
|
||||
sqlalchemy = {version = ">=2.0.0,<2.1.0", extras = ["asyncio"]}
|
||||
|
||||
[[package]]
|
||||
name = "greenlet"
|
||||
version = "3.1.1"
|
||||
|
@ -1520,4 +1536,4 @@ files = [
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.12"
|
||||
content-hash = "756f4a7bf70e40c6b8dadeba9156c8b3e980f3ee5f14d73c9571cc6597cd52ce"
|
||||
content-hash = "48335dd82829883c1d2ac4b19b8ae09d8455bf3b9add9aa6bd83bb07e61336f2"
|
||||
|
|
|
@ -15,7 +15,7 @@ jinja2 = "^3.1.4"
|
|||
alembic = "^1.13.3"
|
||||
asyncpg = "^0.29.0"
|
||||
sqlalchemy = {extras = ["asyncio"], version = "^2.0.35"}
|
||||
fastapi-users = "^13.0.0"
|
||||
fastapi-users = {extras = ["sqlalchemy"], version = "^13.0.0"}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue