diff --git a/main.py b/main.py index 4f37ad1a..49f0db90 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ from importlib import import_module from sqlalchemy import Boolean, MetaData, Table, create_engine -from sqlalchemy.schema import AddConstraint, DropConstraint, ForeignKeyConstraint +from sqlalchemy.schema import AddConstraint, CreateTable, DropConstraint, ForeignKeyConstraint def warninger(message, category, filename, lineno, line=None): @@ -175,7 +175,22 @@ def warninger(message, category, filename, lineno, line=None): if args.drop_first: table.drop(engine, checkfirst=True) - table.create(engine, checkfirst=True) + + # SQLAlchemy neumi SQLite STRICT tables, tak to udelame trochu humpolacky + if engine.name == "sqlite": + ddl = CreateTable(table).compile(engine).string + ddl += " STRICT" + ddl = ddl.replace(" BIGINT", " INT") + ddl = ddl.replace(" SMALLINT", " INT") + ddl = ddl.replace(" DATE", " TEXT") + ddl = ddl.replace(" TIME", " TEXT") + ddl = ddl.replace(" JSON", " TEXT") + ddl = ddl.replace(" BOOLEAN", " INT") + # TODO: NUMERIC + conn = engine.raw_connection() + conn.execute(ddl) + else: + table.create(engine, checkfirst=True) # dropni fkeys pred nahravanim dat # z nejakeho duvodu jsou v sqlite nepojmenovany klice