Forums

Create a table in runtime with Flask-SQLAlchemy

Hi!

Does anyone know if a table can be created in runtime? This can be done with SQLAlchemy, but I don't know if this can be achieved with Flask-SQLAlchemy because they way to access the tables is through the classes declared in the source code.

I would appreciate if anyone could provide some information about this, thanks!

You could do it, certainly, though it would be an unusual thing to do. The trick would probably be to bypass Flask-SQLAlchemy and then create a direct connection to the database. You would then need to use raw SQL to access your new table, though, as (of course) you wouldn't have the classes defined to do it through an ORM.

Ok, thanks, I will try that.