Compare commits

..

5 Commits

31 changed files with 896 additions and 65 deletions

View File

@ -0,0 +1,2 @@
APP_CONFIG__DB__URL = mssql+aioodbc://sa:159357@127.0.0.1:1433/test_db?driver=ODBC+Driver+17+for+SQL+Server
APP_CONFIG__RUN__PORT = 8080

114
backend-app/alembic.ini Normal file
View File

@ -0,0 +1,114 @@
# A generic, single database configuration.
[alembic]
# path to migration scripts.
# Use forward slashes (/) also on windows to provide an os agnostic path
script_location = alembic
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
prepend_sys_path = .
# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the python>=3.9 or backports.zoneinfo library.
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
# string value is passed to ZoneInfo()
# leave blank for localtime
# timezone =
# max length of characters to apply to the "slug" field
# truncate_slug_length = 40
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false
# version location specification; This defaults
# to alembic/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator" below.
# version_locations = %(here)s/bar:%(here)s/bat:alembic/versions
# version path separator; As mentioned above, this is the character used to split
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
# Valid values for version_path_separator are:
#
# version_path_separator = :
# version_path_separator = ;
# version_path_separator = space
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
# set to 'true' to search source files recursively
# in each "version_locations" directory
# new in Alembic version 1.10
# recursive_version_locations = false
# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8
sqlalchemy.url = driver://user:pass@localhost/dbname
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples
# format using "black" - use the console_scripts runner, against the "black" entrypoint
hooks = black
black.type = console_scripts
black.entrypoint = black
black.options = -l 79 REVISION_SCRIPT_FILENAME
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
# hooks = ruff
# ruff.type = exec
# ruff.executable = %(here)s/.venv/bin/ruff
# ruff.options = --fix REVISION_SCRIPT_FILENAME
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

View File

@ -0,0 +1 @@
Generic single-database configuration with an async dbapi.

View File

@ -0,0 +1,90 @@
import asyncio
from logging.config import fileConfig
from sqlalchemy import pool
from sqlalchemy.engine import Connection
from sqlalchemy.ext.asyncio import async_engine_from_config
from core.settings import settings
from core.models.base import Base
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata
config.set_main_option("sqlalchemy.url", settings.db.url)
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def do_run_migrations(connection: Connection) -> None:
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
async def run_async_migrations() -> None:
"""In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = async_engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
async with connectable.connect() as connection:
await connection.run_sync(do_run_migrations)
await connectable.dispose()
def run_migrations_online() -> None:
"""Run migrations in 'online' mode."""
asyncio.run(run_async_migrations())
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

View File

@ -0,0 +1,26 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision: str = ${repr(up_revision)}
down_revision: Union[str, None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}

View File

@ -0,0 +1,53 @@
"""create tables user, login with convention
Revision ID: 43539348d64d
Revises:
Create Date: 2024-07-31 23:03:58.400569
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "43539348d64d"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"logins",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("username", sa.String(length=255), nullable=False),
sa.Column("password", sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_logins")),
sa.UniqueConstraint("username", name=op.f("uq_logins_username")),
)
op.create_table(
"users",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("firstname", sa.String(length=255), nullable=True),
sa.Column("lastname", sa.String(length=255), nullable=True),
sa.Column("age", sa.Integer(), nullable=True),
sa.Column("email", sa.String(length=255), nullable=True),
sa.Column("login_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["login_id"], ["logins.id"], name=op.f("fk_users_login_id_logins")
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_users")),
sa.UniqueConstraint("email", name=op.f("uq_users_email")),
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("users")
op.drop_table("logins")
# ### end Alembic commands ###

View File

@ -0,0 +1,9 @@
from fastapi import APIRouter
from core.settings import settings
from .api_v1 import router as v1_router
router = APIRouter(
prefix= settings.api.prefix,
tags=["Основной роутер"]
)
router.include_router(v1_router)

View File

@ -1,7 +0,0 @@
from fastapi import APIRouter
router = APIRouter()
@router.get("/hello")
async def say_world():
return {"msg":"Hello WORLD!"}

View File

@ -0,0 +1,13 @@
from fastapi import APIRouter
from core.settings import settings
from .login import router as login_router
from .user import router as user_router
router = APIRouter(
prefix=settings.api.v1.prefix,
)
router.include_router(
user_router
)
router.include_router(
login_router
)

View File

@ -0,0 +1,53 @@
from fastapi import APIRouter, Depends
from core.settings import settings
from sqlalchemy.ext.asyncio import AsyncSession
from typing import Annotated
from core.models import db_helper
from repo.schemas import LoginCreate,LoginRead, LoginUpdate
import repo.crud.login as crud
router = APIRouter(
prefix=settings.api.v1.login,
tags=["Login"]
)
@router.get("/", response_model=list[LoginRead])
async def get_all_logins(
session: Annotated[AsyncSession, Depends(db_helper.session_getter)]
):
logins = await crud.get_all_logins(session=session)
return logins
@router.get("/{login_id}", response_model=LoginRead)
async def get_login(
session: Annotated[AsyncSession, Depends(db_helper.session_getter)],
login_id: int
):
login = await crud.get_login(
session=session,
login_id=login_id
)
return login
@router.post("/", response_model=LoginRead)
async def create_login(
session: Annotated[AsyncSession, Depends(db_helper.session_getter)],
login_create: LoginCreate
):
login = await crud.create_login(
session=session,
login_create=login_create
)
return login
@router.patch("/{login_id}", response_model=LoginRead)
async def update_login(
session: Annotated[AsyncSession, Depends(db_helper.session_getter)],
login_id: int,
login_update: LoginUpdate
):
login = await crud.update_login(
session=session,
login_id=login_id,
login_update=login_update
)
return login

View File

@ -0,0 +1,57 @@
from fastapi import APIRouter, Depends
from core.settings import settings
from sqlalchemy.ext.asyncio import AsyncSession
from typing import Annotated
from repo.schemas import UserRead, UserCreate, UserUpdate
from core.models import db_helper
import repo.crud.user as crud
router = APIRouter(
prefix=settings.api.v1.user,
tags=["Users"]
)
@router.get("/", response_model=list[UserRead])
async def get_all_users(
session: Annotated[AsyncSession, Depends(db_helper.session_getter)]
):
users = await crud.get_all_users(session=session)
return users
@router.get("/{user_id}", response_model=UserRead)
async def get_user(
session: Annotated[AsyncSession, Depends(db_helper.session_getter)],
user_id: int
):
users = await crud.get_user(
session=session,
user_id=user_id
)
return users
@router.post("/", response_model=UserRead)
async def create_user(
session: Annotated[AsyncSession, Depends(db_helper.session_getter)],
user_create: UserCreate
):
users = await crud.create_user(
session=session,
user_create=user_create
)
return users
@router.patch("/{user_id}", response_model=UserRead)
async def update_user(
session: Annotated[AsyncSession, Depends(db_helper.session_getter)],
user_id: int,
user_update: UserUpdate
):
users = await crud.update_user(
session=session,
user_id=user_id,
user_update=user_update
)
return users

View File

@ -1,7 +0,0 @@
from fastapi import APIRouter
router = APIRouter()
@router.get("/hello")
async def say_hello():
return {"msg":"hello"}

View File

@ -0,0 +1,4 @@
__all__ = (
"settings"
)
from .settings import settings

View File

@ -0,0 +1,7 @@
__all__ = (
"db_helper",
"Base"
)
from .db_helper import db_helper
from .base import Base
from repo.models import LoginModel, UserModel

View File

@ -0,0 +1,7 @@
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy import MetaData
from core.settings import settings
class Base(DeclarativeBase):
__abstract__ = True
metadata = MetaData(naming_convention=settings.db.convention)

View File

@ -0,0 +1,41 @@
from sqlalchemy.ext.asyncio import create_async_engine, AsyncEngine, async_sessionmaker, AsyncSession
from typing import AsyncGenerator
from core.settings import settings
class DatabaseHelper:
def __init__(
self,
url: str,
echo:bool=False,
echo_pool:bool=False,
pool_size: int = 5,
max_overflow: int =10,
) -> None:
self.engine: AsyncEngine = create_async_engine(
url=url,
echo=echo,
echo_pool=echo_pool,
pool_size=pool_size,
max_overflow = max_overflow
)
self.session_factory: async_sessionmaker[AsyncSession] = async_sessionmaker(
bind= self.engine,
autoflush=False,
autocommit=False,
expire_on_commit=False
)
async def dispose(self) -> None:
await self.engine.dispose()
async def session_getter(self) -> AsyncGenerator[AsyncSession,None]:
async with self.session_factory() as session:
yield session
db_helper = DatabaseHelper(
url = settings.db.url,
echo = settings.db.echo,
echo_pool = settings.db.echo_pool,
pool_size = settings.db.pool_size,
max_overflow = settings.db.max_overflow,
)

View File

@ -1,11 +1,42 @@
from pydantic_settings import BaseSettings from pydantic_settings import BaseSettings, SettingsConfigDict
from pydantic import BaseModel from pydantic import BaseModel
class RunSettings(BaseModel): class RunSettings(BaseModel):
host: str = "0.0.0.0" host: str = "0.0.0.0"
port: int = 8000 port: int = 8000
class Settings(BaseSettings): class APIV1Prefix(BaseModel):
run: RunSettings = RunSettings() prefix:str = "/v1"
user:str = "/user"
login:str = "/login"
settings = Settings() class APIPrefix(BaseModel):
prefix:str = "/api"
v1: APIV1Prefix = APIV1Prefix()
class DatabaseConfig(BaseModel):
url: str
echo:bool=False
echo_pool:bool=False
pool_size: int = 50
max_overflow: int =10
convention:dict = {
"ix": "ix_%(column_0_label)s",
"uq": "uq_%(table_name)s_%(column_0_name)s",
"ck": "ck_%(table_name)s_%(constraint_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"pk": "pk_%(table_name)s",
}
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=".env",
case_sensitive=False,
env_nested_delimiter="__",
env_prefix="APP_CONFIG__"
)
run: RunSettings = RunSettings()
db: DatabaseConfig
api: APIPrefix = APIPrefix()
settings = Settings()

View File

@ -1,23 +0,0 @@
from sqlalchemy.ext.asyncio import async_sessionmaker, AsyncSession, create_async_engine
from sqlalchemy.orm import DeclarativeBase
class Model(DeclarativeBase):
pass
async_engine=create_async_engine(
url = "mssql+aioodbc://sa:159357"\
"@10.124.30.208:1433/test_db"\
"?driver=ODBC+Driver+17+for+SQL+Server",
connect_args={"check_same_thread": False}
)
async_session = async_sessionmaker(
async_engine,
autoflush=True,
autocommit=False,
expire_on_commit =False
)
# async def get_async_session() -> AsyncSession:
# async with async_session() as session:
# session.

View File

@ -2,23 +2,24 @@ import uvicorn
from fastapi import FastAPI, HTTPException from fastapi import FastAPI, HTTPException
from fastapi.responses import ORJSONResponse from fastapi.responses import ORJSONResponse
from core.settings import settings from core.settings import settings
from api.main_router import router as main_router from api import router
from api.another_router import router as another_router from core.models import db_helper
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app: FastAPI):
#start up
yield
#shutdown
await db_helper.dispose()
app = FastAPI(default_response_class=ORJSONResponse) main_app = FastAPI(
lifespan=lifespan,
default_response_class=ORJSONResponse
)
#api/hello #api/hello
app.include_router( main_app.include_router(router)
router=main_router,
prefix="/api",
tags=["Основной роутер"]
)
app.include_router(
router=another_router,
prefix="/another",
tags=["Побочный роутер"]
)
if __name__ == "__main__": if __name__ == "__main__":
uvicorn.run(app, host=settings.run.host, port=settings.run.port) uvicorn.run(main_app, host=settings.run.host, port=settings.run.port)

View File

@ -0,0 +1,5 @@
__all__ = (
"UserModel",
"LoginModel"
)
from .models import UserModel, LoginModel

View File

@ -0,0 +1,57 @@
from typing import Sequence
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select, delete, update
from ..schemas import LoginRead, LoginCreate, LoginUpdate
from ..models import LoginModel
from utils.hashing import get_password_hash
async def get_all_logins(
session: AsyncSession
) -> Sequence[LoginModel]:
stmt = select(LoginModel).order_by(LoginModel.id)
result = await session.scalars(stmt)
return result.all()
async def get_login(
session: AsyncSession,
login_id: int
) -> LoginModel:
db_login = await session.get(LoginModel,login_id)
if db_login is None:
return None
return db_login
async def create_login(
session:AsyncSession,
login_create: LoginCreate
) -> LoginModel:
login = LoginModel(**login_create.model_dump())
login.password = get_password_hash(login.password)
session.add(login)
await session.commit()
return login
async def delete_login(
session: AsyncSession,
login_id: int
):
db_login = await session.get(LoginModel,login_id)
if db_login is None:
return None
stmt = delete(LoginModel).filter(LoginModel.id == login_id)
await session.execute(stmt)
await session.commit()
async def update_login(
session:AsyncSession,
login_id: int,
login_update: LoginUpdate
) -> LoginModel:
db_login = await session.get(LoginModel,login_id)
if db_login is None:
return None
for var, value in vars(login_update).items():
setattr(db_login, var, value if var != "password" else get_password_hash(value)) if value else None
await session.commit()
return db_login

View File

@ -0,0 +1,58 @@
from typing import Sequence
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select, delete, update
from ..schemas import UserRead, UserCreate,UserUpdate
from ..models import UserModel
async def get_all_users(
session: AsyncSession
) -> Sequence[UserModel]:
stmt = select(UserModel).order_by(UserModel.id)
result = await session.scalars(stmt)
return result.all()
async def get_user(
session: AsyncSession,
user_id: int
) -> UserModel:
db_user = await session.get(UserModel, user_id)
if db_user is None:
return None
return db_user
async def create_user(
session:AsyncSession,
user_create: UserCreate
) -> UserModel:
user = UserModel(**user_create.model_dump())
session.add(user)
await session.commit()
return user
async def delete_user(
session: AsyncSession,
user_id: int
) -> UserModel:
db_user = await session.get(UserModel, user_id)
if db_user is None:
return None
stmt = delete(UserModel).filter(UserModel.id == user_id)
await session.execute(stmt)
await session.commit()
return db_user.one_or_none()
async def update_user(
session:AsyncSession,
user_id: int,
user_update: UserUpdate
) -> UserModel:
db_user = await session.get(UserModel, user_id)
if db_user is None:
return None
for var, value in vars(user_update).items():
setattr(db_user, var, value) if value else None
await session.commit()
await session.refresh(db_user)
return db_user

View File

@ -1,21 +1,21 @@
from database import Model from core.models import Base
from sqlalchemy.orm import Mapped, mapped_column from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import String, Integer, Boolean, ForeignKey from sqlalchemy import String, Integer, Boolean, ForeignKey
from typing import Optional, Sequence from typing import Optional, Sequence
class UserModel(Model): class UserModel(Base):
__tablename__ ="users" __tablename__ ="users"
id: Mapped[int] = mapped_column(Integer, primary_key=True) id: Mapped[int] = mapped_column(Integer, primary_key=True)
firstname: Mapped[str | None]= mapped_column(String(255), nullable=True) firstname: Mapped[str | None]= mapped_column(String(255), nullable=True)
lastname: Mapped[str | None]= mapped_column(String(255), nullable=True) lastname: Mapped[str | None]= mapped_column(String(255), nullable=True)
age: Mapped[int | None] = mapped_column(Integer, nullable=True) age: Mapped[int | None] = mapped_column(Integer, nullable=True)
email: Mapped[str | None] = mapped_column(String(255), nullable=True) email: Mapped[str | None] = mapped_column(String(255), nullable=True, unique=True)
login_id: Mapped[int] = mapped_column(Integer, ForeignKey("logins.id")) login_id: Mapped[int] = mapped_column(Integer, ForeignKey("logins.id"))
class LoginModel(Model): class LoginModel(Base):
__tablename__ ="logins" __tablename__ ="logins"
id: Mapped[int] = mapped_column(Integer, primary_key=True) id: Mapped[int] = mapped_column(Integer, primary_key=True)
login: Mapped[str]= mapped_column(String(255), nullable=False) username: Mapped[str]= mapped_column(String(255), nullable=False, unique=True)
password: Mapped[str]= mapped_column(String(255), nullable=False) password: Mapped[str]= mapped_column(String(255), nullable=False)

View File

@ -1,2 +0,0 @@
from pydantic import BaseModel

View File

@ -0,0 +1,33 @@
from pydantic import BaseModel, EmailStr
from typing import Optional, Sequence
class LoginBase(BaseModel):
username:str
password:str
class LoginUpdate(BaseModel):
username:Optional[str] = None
password:Optional[str] = None
class LoginCreate(LoginBase):
pass
class LoginRead(LoginBase):
id:int
class UserUpdate(BaseModel):
firstname:Optional[str] = None
lastname:Optional[str] = None
age: Optional[int] = None
email: Optional[EmailStr] = None
class UserBase(UserUpdate):
login_id: int
class UserCreate(UserBase):
pass
class UserRead(UserBase):
id:int

View File

View File

@ -0,0 +1,9 @@
from passlib.context import CryptContext
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def verify_password(plain_password, hashed_password):
return pwd_context.verify(plain_password, hashed_password)
def get_password_hash(password):
return pwd_context.hash(password)

190
poetry.lock generated
View File

@ -14,6 +14,25 @@ files = [
[package.dependencies] [package.dependencies]
pyodbc = ">=5.0.1" pyodbc = ">=5.0.1"
[[package]]
name = "alembic"
version = "1.13.2"
description = "A database migration tool for SQLAlchemy."
optional = false
python-versions = ">=3.8"
files = [
{file = "alembic-1.13.2-py3-none-any.whl", hash = "sha256:6b8733129a6224a9a711e17c99b08462dbf7cc9670ba8f2e2ae9af860ceb1953"},
{file = "alembic-1.13.2.tar.gz", hash = "sha256:1ff0ae32975f4fd96028c39ed9bb3c867fe3af956bd7bb37343b54c9fe7445ef"},
]
[package.dependencies]
Mako = "*"
SQLAlchemy = ">=1.3.0"
typing-extensions = ">=4"
[package.extras]
tz = ["backports.zoneinfo"]
[[package]] [[package]]
name = "annotated-types" name = "annotated-types"
version = "0.7.0" version = "0.7.0"
@ -45,6 +64,90 @@ doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphin
test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"]
trio = ["trio (>=0.23)"] trio = ["trio (>=0.23)"]
[[package]]
name = "bcrypt"
version = "4.2.0"
description = "Modern password hashing for your software and your servers"
optional = false
python-versions = ">=3.7"
files = [
{file = "bcrypt-4.2.0-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:096a15d26ed6ce37a14c1ac1e48119660f21b24cba457f160a4b830f3fe6b5cb"},
{file = "bcrypt-4.2.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c02d944ca89d9b1922ceb8a46460dd17df1ba37ab66feac4870f6862a1533c00"},
{file = "bcrypt-4.2.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1d84cf6d877918620b687b8fd1bf7781d11e8a0998f576c7aa939776b512b98d"},
{file = "bcrypt-4.2.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:1bb429fedbe0249465cdd85a58e8376f31bb315e484f16e68ca4c786dcc04291"},
{file = "bcrypt-4.2.0-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:655ea221910bcac76ea08aaa76df427ef8625f92e55a8ee44fbf7753dbabb328"},
{file = "bcrypt-4.2.0-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:1ee38e858bf5d0287c39b7a1fc59eec64bbf880c7d504d3a06a96c16e14058e7"},
{file = "bcrypt-4.2.0-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:0da52759f7f30e83f1e30a888d9163a81353ef224d82dc58eb5bb52efcabc399"},
{file = "bcrypt-4.2.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:3698393a1b1f1fd5714524193849d0c6d524d33523acca37cd28f02899285060"},
{file = "bcrypt-4.2.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:762a2c5fb35f89606a9fde5e51392dad0cd1ab7ae64149a8b935fe8d79dd5ed7"},
{file = "bcrypt-4.2.0-cp37-abi3-win32.whl", hash = "sha256:5a1e8aa9b28ae28020a3ac4b053117fb51c57a010b9f969603ed885f23841458"},
{file = "bcrypt-4.2.0-cp37-abi3-win_amd64.whl", hash = "sha256:8f6ede91359e5df88d1f5c1ef47428a4420136f3ce97763e31b86dd8280fbdf5"},
{file = "bcrypt-4.2.0-cp39-abi3-macosx_10_12_universal2.whl", hash = "sha256:c52aac18ea1f4a4f65963ea4f9530c306b56ccd0c6f8c8da0c06976e34a6e841"},
{file = "bcrypt-4.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3bbbfb2734f0e4f37c5136130405332640a1e46e6b23e000eeff2ba8d005da68"},
{file = "bcrypt-4.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3413bd60460f76097ee2e0a493ccebe4a7601918219c02f503984f0a7ee0aebe"},
{file = "bcrypt-4.2.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:8d7bb9c42801035e61c109c345a28ed7e84426ae4865511eb82e913df18f58c2"},
{file = "bcrypt-4.2.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:3d3a6d28cb2305b43feac298774b997e372e56c7c7afd90a12b3dc49b189151c"},
{file = "bcrypt-4.2.0-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:9c1c4ad86351339c5f320ca372dfba6cb6beb25e8efc659bedd918d921956bae"},
{file = "bcrypt-4.2.0-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:27fe0f57bb5573104b5a6de5e4153c60814c711b29364c10a75a54bb6d7ff48d"},
{file = "bcrypt-4.2.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:8ac68872c82f1add6a20bd489870c71b00ebacd2e9134a8aa3f98a0052ab4b0e"},
{file = "bcrypt-4.2.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:cb2a8ec2bc07d3553ccebf0746bbf3d19426d1c6d1adbd4fa48925f66af7b9e8"},
{file = "bcrypt-4.2.0-cp39-abi3-win32.whl", hash = "sha256:77800b7147c9dc905db1cba26abe31e504d8247ac73580b4aa179f98e6608f34"},
{file = "bcrypt-4.2.0-cp39-abi3-win_amd64.whl", hash = "sha256:61ed14326ee023917ecd093ee6ef422a72f3aec6f07e21ea5f10622b735538a9"},
{file = "bcrypt-4.2.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:39e1d30c7233cfc54f5c3f2c825156fe044efdd3e0b9d309512cc514a263ec2a"},
{file = "bcrypt-4.2.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:f4f4acf526fcd1c34e7ce851147deedd4e26e6402369304220250598b26448db"},
{file = "bcrypt-4.2.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:1ff39b78a52cf03fdf902635e4c81e544714861ba3f0efc56558979dd4f09170"},
{file = "bcrypt-4.2.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:373db9abe198e8e2c70d12b479464e0d5092cc122b20ec504097b5f2297ed184"},
{file = "bcrypt-4.2.0.tar.gz", hash = "sha256:cf69eaf5185fd58f268f805b505ce31f9b9fc2d64b376642164e9244540c1221"},
]
[package.extras]
tests = ["pytest (>=3.2.1,!=3.3.0)"]
typecheck = ["mypy"]
[[package]]
name = "black"
version = "24.4.2"
description = "The uncompromising code formatter."
optional = false
python-versions = ">=3.8"
files = [
{file = "black-24.4.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dd1b5a14e417189db4c7b64a6540f31730713d173f0b63e55fabd52d61d8fdce"},
{file = "black-24.4.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8e537d281831ad0e71007dcdcbe50a71470b978c453fa41ce77186bbe0ed6021"},
{file = "black-24.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eaea3008c281f1038edb473c1aa8ed8143a5535ff18f978a318f10302b254063"},
{file = "black-24.4.2-cp310-cp310-win_amd64.whl", hash = "sha256:7768a0dbf16a39aa5e9a3ded568bb545c8c2727396d063bbaf847df05b08cd96"},
{file = "black-24.4.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:257d724c2c9b1660f353b36c802ccece186a30accc7742c176d29c146df6e474"},
{file = "black-24.4.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:bdde6f877a18f24844e381d45e9947a49e97933573ac9d4345399be37621e26c"},
{file = "black-24.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e151054aa00bad1f4e1f04919542885f89f5f7d086b8a59e5000e6c616896ffb"},
{file = "black-24.4.2-cp311-cp311-win_amd64.whl", hash = "sha256:7e122b1c4fb252fd85df3ca93578732b4749d9be076593076ef4d07a0233c3e1"},
{file = "black-24.4.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:accf49e151c8ed2c0cdc528691838afd217c50412534e876a19270fea1e28e2d"},
{file = "black-24.4.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:88c57dc656038f1ab9f92b3eb5335ee9b021412feaa46330d5eba4e51fe49b04"},
{file = "black-24.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be8bef99eb46d5021bf053114442914baeb3649a89dc5f3a555c88737e5e98fc"},
{file = "black-24.4.2-cp312-cp312-win_amd64.whl", hash = "sha256:415e686e87dbbe6f4cd5ef0fbf764af7b89f9057b97c908742b6008cc554b9c0"},
{file = "black-24.4.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:bf10f7310db693bb62692609b397e8d67257c55f949abde4c67f9cc574492cc7"},
{file = "black-24.4.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:98e123f1d5cfd42f886624d84464f7756f60ff6eab89ae845210631714f6db94"},
{file = "black-24.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:48a85f2cb5e6799a9ef05347b476cce6c182d6c71ee36925a6c194d074336ef8"},
{file = "black-24.4.2-cp38-cp38-win_amd64.whl", hash = "sha256:b1530ae42e9d6d5b670a34db49a94115a64596bc77710b1d05e9801e62ca0a7c"},
{file = "black-24.4.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:37aae07b029fa0174d39daf02748b379399b909652a806e5708199bd93899da1"},
{file = "black-24.4.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:da33a1a5e49c4122ccdfd56cd021ff1ebc4a1ec4e2d01594fef9b6f267a9e741"},
{file = "black-24.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ef703f83fc32e131e9bcc0a5094cfe85599e7109f896fe8bc96cc402f3eb4b6e"},
{file = "black-24.4.2-cp39-cp39-win_amd64.whl", hash = "sha256:b9176b9832e84308818a99a561e90aa479e73c523b3f77afd07913380ae2eab7"},
{file = "black-24.4.2-py3-none-any.whl", hash = "sha256:d36ed1124bb81b32f8614555b34cc4259c3fbc7eec17870e8ff8ded335b58d8c"},
{file = "black-24.4.2.tar.gz", hash = "sha256:c872b53057f000085da66a19c55d68f6f8ddcac2642392ad3a355878406fbd4d"},
]
[package.dependencies]
click = ">=8.0.0"
mypy-extensions = ">=0.4.3"
packaging = ">=22.0"
pathspec = ">=0.9.0"
platformdirs = ">=2"
[package.extras]
colorama = ["colorama (>=0.4.3)"]
d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"]
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
uvloop = ["uvloop (>=0.15.2)"]
[[package]] [[package]]
name = "certifi" name = "certifi"
version = "2024.7.4" version = "2024.7.4"
@ -361,6 +464,25 @@ MarkupSafe = ">=2.0"
[package.extras] [package.extras]
i18n = ["Babel (>=2.7)"] i18n = ["Babel (>=2.7)"]
[[package]]
name = "mako"
version = "1.3.5"
description = "A super-fast templating language that borrows the best ideas from the existing templating languages."
optional = false
python-versions = ">=3.8"
files = [
{file = "Mako-1.3.5-py3-none-any.whl", hash = "sha256:260f1dbc3a519453a9c856dedfe4beb4e50bd5a26d96386cb6c80856556bb91a"},
{file = "Mako-1.3.5.tar.gz", hash = "sha256:48dbc20568c1d276a2698b36d968fa76161bf127194907ea6fc594fa81f943bc"},
]
[package.dependencies]
MarkupSafe = ">=0.9.2"
[package.extras]
babel = ["Babel"]
lingua = ["lingua"]
testing = ["pytest"]
[[package]] [[package]]
name = "markdown-it-py" name = "markdown-it-py"
version = "3.0.0" version = "3.0.0"
@ -465,6 +587,17 @@ files = [
{file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"},
] ]
[[package]]
name = "mypy-extensions"
version = "1.0.0"
description = "Type system extensions for programs checked with the mypy type checker."
optional = false
python-versions = ">=3.5"
files = [
{file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"},
{file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"},
]
[[package]] [[package]]
name = "orjson" name = "orjson"
version = "3.10.6" version = "3.10.6"
@ -525,6 +658,61 @@ files = [
{file = "orjson-3.10.6.tar.gz", hash = "sha256:e54b63d0a7c6c54a5f5f726bc93a2078111ef060fec4ecbf34c5db800ca3b3a7"}, {file = "orjson-3.10.6.tar.gz", hash = "sha256:e54b63d0a7c6c54a5f5f726bc93a2078111ef060fec4ecbf34c5db800ca3b3a7"},
] ]
[[package]]
name = "packaging"
version = "24.1"
description = "Core utilities for Python packages"
optional = false
python-versions = ">=3.8"
files = [
{file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"},
{file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"},
]
[[package]]
name = "passlib"
version = "1.7.4"
description = "comprehensive password hashing framework supporting over 30 schemes"
optional = false
python-versions = "*"
files = [
{file = "passlib-1.7.4-py2.py3-none-any.whl", hash = "sha256:aa6bca462b8d8bda89c70b382f0c298a20b5560af6cbfa2dce410c0a2fb669f1"},
{file = "passlib-1.7.4.tar.gz", hash = "sha256:defd50f72b65c5402ab2c573830a6978e5f202ad0d984793c8dde2c4152ebe04"},
]
[package.extras]
argon2 = ["argon2-cffi (>=18.2.0)"]
bcrypt = ["bcrypt (>=3.1.0)"]
build-docs = ["cloud-sptheme (>=1.10.1)", "sphinx (>=1.6)", "sphinxcontrib-fulltoc (>=1.2.0)"]
totp = ["cryptography"]
[[package]]
name = "pathspec"
version = "0.12.1"
description = "Utility library for gitignore style pattern matching of file paths."
optional = false
python-versions = ">=3.8"
files = [
{file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"},
{file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"},
]
[[package]]
name = "platformdirs"
version = "4.2.2"
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`."
optional = false
python-versions = ">=3.8"
files = [
{file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"},
{file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"},
]
[package.extras]
docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"]
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"]
type = ["mypy (>=1.8)"]
[[package]] [[package]]
name = "pydantic" name = "pydantic"
version = "2.8.2" version = "2.8.2"
@ -1222,4 +1410,4 @@ files = [
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.12" python-versions = "^3.12"
content-hash = "c354748ac55aa1d7c444388106be2183e21b59f54bf1629a6b5b8c7da70eaf97" content-hash = "ad4b72b47db69c4361a78a797531725b35c4810580a1f160bcf8f57872f61ffd"

View File

@ -8,3 +8,7 @@ pydantic-settings = "^2.4.0"
sqlalchemy = {extras = ["asyncio"], version = "^2.0.31"} sqlalchemy = {extras = ["asyncio"], version = "^2.0.31"}
aioodbc = "^0.5.0" aioodbc = "^0.5.0"
orjson = "^3.10.6" orjson = "^3.10.6"
alembic = "^1.13.2"
black = "^24.4.2"
passlib = "^1.7.4"
bcrypt = "^4.2.0"

View File

@ -2,7 +2,9 @@
2. Установка poetry 2. Установка poetry
pip install poetry pip install poetry
3. Создание папки проекта и добавить в него файл pyproject.toml с данными 3. Создание папки проекта и добавить в него файл pyproject.toml с данными
[markdown]
[tool.poetry] [tool.poetry]
[markdown]
package-mode = false package-mode = false
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.12" python = "^3.12"
@ -12,4 +14,9 @@ poetry install
poetry add fastapi uvicorn[standart] pydantic-settings sqlalchemy[asyncio] aioodbc orjson poetry add fastapi uvicorn[standart] pydantic-settings sqlalchemy[asyncio] aioodbc orjson
6. Создаем гит проект для нашего приложения 6. Создаем гит проект для нашего приложения
git init git init
7. Добавляем файл .gitignore 7. Добавляем файл .gitignore
8. Alembic
alembic revision --autogenerate -m "create tables user, login"
alembic upgrade head