Is it possible to use raw SQL rather than the TABLE construct for creating tables in SQL Alchemy? I would still like to use the rest of SQLAlchemy though, such as the object mapper and session module. I'm just not fond of the SQLAlchemy syntax used to create开发者_高级运维 tables (I've spent too long mired in SAS and SQL to learn another!).
Many thanks, Rich
Yes.
connection.execute("""
CREATE TABLE ...
""")
You can then reflect all tables: MetaData(dsn, reflect=True) or metadata_instance.reflect().
You can use the autoload paramater to the Table constructor to have it automatically load up the table definitions. There are some examples here.
加载中,请稍侯......
精彩评论