1

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(Useretc) 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.

1 Answer 1

3

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).

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

1 Comment

And you were right, only we are able to access those tables for each model.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.