forked from oscar.krause/fastapi-dls
fixed - sqlalchemy.exc.ArgumentError: Textual SQL expression '\nCREATE TABLE origin (\n\to...' should be explicitly declared as text('\nCREATE TABLE origin (\n\to...')
This commit is contained in:
parent
f540c4b25b
commit
62d347510d
@ -1,7 +1,7 @@
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from sqlalchemy import Column, VARCHAR, CHAR, ForeignKey, DATETIME, update, and_, inspect
|
||||
from sqlalchemy import Column, VARCHAR, CHAR, ForeignKey, DATETIME, update, and_, inspect, text
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
@ -190,7 +190,7 @@ def init(engine: Engine):
|
||||
session = sessionmaker(bind=engine)()
|
||||
for table in tables:
|
||||
if not db.dialect.has_table(engine.connect(), table.__tablename__):
|
||||
session.execute(str(table.create_statement(engine)))
|
||||
session.execute(text(str(table.create_statement(engine))))
|
||||
session.commit()
|
||||
session.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user