Use raw SQL to create tables in SQLAlchemy, then use ORM

Is it possible to use raw SQL and not the TABLE construct to create tables in SQL Alchemy? I would still like to use the rest of SQLAlchemy, for example, to map objects to a session module. I just don't like the SQLAlchemy syntax used to create tables (I worked in SAS and SQL for too long to find out more!).

Thanks a lot Rich

+4
source share
2 answers

Yes.

connection.execute(""" CREATE TABLE ... """) 

Then you can display all the tables: MetaData(dsn, reflect=True) or metadata_instance.reflect() .

+3
source

You can use the autoload parameter for the Table constructor so that it automatically autoload table definitions. Here are some examples here .

+1
source

All Articles