4

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

2 Answers 2

3

Yes.

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

You can then reflect all tables: MetaData(dsn, reflect=True) or metadata_instance.reflect().

Sign up to request clarification or add additional context in comments.

Comments

1

You can use the autoload paramater to the Table constructor to have it automatically load up the table definitions. There are some examples here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.