[ACCEPTED]-How to generate a file with DDL in the engine's SQL dialect in SQLAlchemy?-sqlalchemy
The quick answer is in the SQLAlchemy 0.8 FAQ.
In SQLAlchemy 12 0.8 you need to do
engine = create_engine( 'mssql+pyodbc://./MyDb', strategy='mock', executor= lambda sql, *multiparams, **params: print (sql.compile(dialect=engine.dialect)))
In SQLAlchemy 0.9 the 11 syntax is simplified.
engine = create_engine( 'mssql+pyodbc://./MyDb', strategy='mock', executor= lambda sql, *multiparams, **params: print (sql)
The longer answer is 10 that capturing the output still has some 9 slight issues. Like with the encoding of 8 literals of types. But this hasn't been 7 a big enough of an issue for anyone to step 6 up and scratch their itch. You could always 5 let SQLAlchemy programmatically create an 4 empty database and dump the SQL from there.
The 3 more difficult problem is the handling of 2 schema migrations. This is where SQLAlchemy-migrate can help 1 you.
More Related questions