forked from edward/owl-map
37 lines
930 B
Python
Executable file
37 lines
930 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
from sqlalchemy.schema import CreateIndex, CreateTable
|
|
|
|
from config.default import DB_USER, DB_NAME
|
|
from matcher import database, model
|
|
|
|
DB_URL = f"postgresql://{DB_USER}@localhost/{DB_NAME}"
|
|
database.init_db(DB_URL)
|
|
|
|
|
|
def create_db():
|
|
model.Base.metadata.create_all(database.session.get_bind())
|
|
|
|
|
|
def print_create_table(classes):
|
|
database.init_db(DB_URL)
|
|
|
|
engine = database.session.get_bind()
|
|
|
|
for cls in classes:
|
|
sql = str(CreateTable(cls.__table__).compile(engine))
|
|
print(sql.strip() + ";")
|
|
|
|
for index in cls.__table__.indexes:
|
|
sql = str(CreateIndex(index).compile(engine))
|
|
print(sql.strip() + ";")
|
|
|
|
|
|
# print_create_table([model.ItemIsA])
|
|
# print_create_table([model.EditSession])
|
|
# print_create_table([model.Changeset, model.ChangesetEdit, model.SkipIsA])
|
|
# print_create_table([model.User])
|
|
# print_create_table([model.Extract])
|
|
|
|
create_db()
|