mirror of
https://github.com/kevin-DL/full-stack-fastapi-postgresql.git
synced 2026-01-14 02:54:44 +00:00
12 lines
267 B
Python
12 lines
267 B
Python
from sqlalchemy.ext.declarative import declarative_base, declared_attr
|
|
|
|
|
|
class CustomBase(object):
|
|
# Generate __tablename__ automatically
|
|
@declared_attr
|
|
def __tablename__(cls):
|
|
return cls.__name__.lower()
|
|
|
|
|
|
Base = declarative_base(cls=CustomBase)
|