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

asked Jan 2, 2010 at 20:56

2 Answers 2

3

Yes.

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

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

answered Jan 2, 2010 at 20:59
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.

answered Jan 3, 2010 at 8:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.