Template
Add sqlalchemy and alembic
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
from ..config import Config
|
||||
|
||||
|
||||
def get_engine(config: Config):
|
||||
engine = create_engine(config.DB_URL,
|
||||
pool_recycle=3600,
|
||||
pool_pre_ping=True)
|
||||
return engine
|
||||
|
||||
|
||||
class Base (DeclarativeBase):
|
||||
pass
|
||||
@@ -0,0 +1,12 @@
|
||||
from sqlalchemy import BIGINT, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from . import Base
|
||||
|
||||
|
||||
class User (Base):
|
||||
__tablename__ = "user"
|
||||
|
||||
id: Mapped[int] = mapped_column(BIGINT, primary_key=True, unique=True, autoincrement=False)
|
||||
username: Mapped[int] = mapped_column(String(32), unique=True, nullable=True)
|
||||
# additional fields go here
|
||||
Reference in New Issue
Block a user