Files
group_fqcd_jr/tools/inspect_platform_schema.py

18 lines
604 B
Python

import sys
from pathlib import Path
from sqlalchemy import create_engine, inspect
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from app.core.config import get_settings
if __name__ == "__main__":
engine = create_engine(get_settings().mysql_dsn.replace("mysql+asyncmy", "mysql+pymysql"))
inspector = inspect(engine)
for name in sys.argv[1:]:
print(name)
for column in inspector.get_columns(name):
print(column["name"], column["type"],
"nullable" if column["nullable"] else "required", column.get("default"))
engine.dispose()