lerafoxqueen/LeraFoxQueen/database.py

46 lines
1.4 KiB
Python

# from datetime import datetime
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
engine = create_async_engine("sqlite+aiosqlite:///datings.db", echo=True)
new_session = async_sessionmaker(engine, expire_on_commit=False)
class Model(DeclarativeBase):
pass
class DatingOrm(Model):
__tablename__ = "datings"
id: Mapped[int] = mapped_column(primary_key=True, unique=True, autoincrement=True)
sessionkey: Mapped[str] = mapped_column(unique=True)
theme_name: Mapped[str]
sender_name: Mapped[str]
sender_sex: Mapped[str]
sender_age: Mapped[int]
sender_city: Mapped[str]
telegram_name: Mapped[str]
interests_in_school_university: Mapped[str]
interests_in_sports: Mapped[str]
interests_in_work: Mapped[str]
interests_in_your_free_time: Mapped[str]
pets_plants_fish: Mapped[str]
relationships_with_relatives_and_friends: Mapped[str]
past_relationships: Mapped[str]
life_principles_values: Mapped[str]
goals_in_life: Mapped[str]
message_text: Mapped[str]
privacy_accept: Mapped[bool]
async def create_tables():
async with engine.begin() as conn:
await conn.run_sync(Model.metadata.create_all)
async def delete_tables():
async with engine.begin() as conn:
await conn.run_sync(Model.metadata.drop_all)