Reputation: 301
Is there a way to create a table without using Base.metadata.create_all()
. I'm looking for something like Mytable.create()
which should create only its corresponding table.
The reason I want to do so is because i'm using Postgres schemas for a multi-tenant web app and I want to create the public
tables(User
etc) separately and the user specific(each having a separate schema, ex. Blog
,Post
) tables when the user signs up. However all the definitions lie in the same file and it seems that create_all creates all the tables defined in the file.
Upvotes: 1
Views: 843
Reputation: 77082
Please read documentation Creating and Dropping Database Tables.
You can do user_table.create(engine)
, or if you are using declarative extension: User.__table__.create(engine)
.
Upvotes: 3