sector119 <sector...@gmail.com> wrote:

> Michael, I want to set search_path to locality schema that depends on user 
> settings.

that’s more like multi-tenancy.   much easier, you don’t have to bother 
creating multiple models.

> 
> And I have some kind of admin utility where user can setup locality 
> environment (schema) with set of tables and I have the list of models those 
> should be created at some schema that admin-user would specify..
> 
> How can I create those list of Models at some table?

We’d like to add a “schema” feature to “execution options”, such that an 
individual set of DB operations can proceed by adding some “schema” to all 
tables or a subset of tables, but that’s a future feature.  In PG, we have 
search_path.  So you should just set up search_path as you need before you 
perform some operation.   Such as, you want to emit a create_all:


with engine.connect() as conn:
    conn.execute(“set search_path = <….>”)
    Base.metadata.create_all(conn)

that’s all you need at that level, unless things are more complicated (like, 
you need to create tables in multiple schemas of variable names…for that I’d 
use an execution event that rewrites schema names).




> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to