1

I have the following ORM mapping using SqlAlchemy:

class Foo(Base):
 __tablename__ = "foo"
 id = Column(Integer, primary_key=True)
 name = Column(String)
 date_imported = Column(DateTime)

However, how can I either get the CREATE TABLE sql syntax or how I can I have it create the table for me?

asked Apr 29, 2014 at 16:55

1 Answer 1

1

Use Foo.__table__.create(bind=engine, checkfirst=True) to issue the statement for that table, or metadata.create_all(bind=engine) to issue the statements for all tables registered on that metadata. If you are using Flask-SQLAlchemy, use db.create_all() to honor binds correctly.

answered Apr 29, 2014 at 17:07
0

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.