first commit
This commit is contained in:
0
db/__init__.py
Normal file
0
db/__init__.py
Normal file
4
db/base.py
Normal file
4
db/base.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
|
||||
class Base(DeclarativeBase): ...
|
||||
3
db/models/__init__.py
Normal file
3
db/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .users import User
|
||||
|
||||
__all__ = ["User"]
|
||||
14
db/models/users.py
Normal file
14
db/models/users.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from sqlalchemy import BIGINT
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from db.base import Base
|
||||
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id: Mapped[int] = mapped_column(
|
||||
BIGINT, nullable=False, unique=True, primary_key=True
|
||||
)
|
||||
support_thread_id: Mapped[int] = mapped_column(BIGINT, nullable=True, unique=True)
|
||||
referal_id: Mapped[int] = mapped_column(BIGINT, nullable=True)
|
||||
6
db/session.py
Normal file
6
db/session.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
|
||||
|
||||
from config import settings
|
||||
|
||||
engine = create_async_engine(settings.postgres_url, echo=True)
|
||||
async_session = async_sessionmaker(bind=engine, expire_on_commit=False)
|
||||
Reference in New Issue
Block a user