Import MetaData and add naming convention
This commit is contained in:
1 parent
2089ce953e
commit
3e0cfc3aae
1 file changed
+18
-2
+18
-2
@@ -8,14 +8,30 @@ import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from sqlalchemy import create_engine, Date, Integer, String
|
||||
from sqlalchemy import create_engine, Date, Integer, MetaData, String
|
||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, sessionmaker
|
||||
|
||||
|
||||
load_dotenv()
|
||||
|
||||
"""
|
||||
Databse naming conventions.
|
||||
ix == index
|
||||
uq == unique constraint
|
||||
ck == check constraint
|
||||
fk == foreign key
|
||||
pk == primary key
|
||||
"""
|
||||
DATABASE_NAMING_CONVENTION = {
|
||||
"ix": "ix_%(table)s_%(column_0_label)s",
|
||||
"uq": "uq_%(table)s_%(column_0_label)s",
|
||||
"ck": "ck_%(table)s_%(column_0_label)s",
|
||||
"fk": "fk_%(table)s_%(column_0_label)s",
|
||||
"pk": "pk_%(table)s_%(column_0_label)s",
|
||||
}
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
metadata = MetaData(naming_convention=DATABASE_NAMING_CONVENTION)
|
||||
|
||||
|
||||
class DataAccessLayer:
|
||||
|
||||
Reference in new issue
Block a user