Currently schema requires that you provide a schema for each table
that is not in the primary metadata.

Example:

main_engine = sa.create_engine('mysql://user:p...@localhost/main')
other_engine = sa.create_engine('mysql://user:p...@localhost/other')

main_metadata = MetaData()
other_metadata = MetaData()

MainBase = declarative_base(metadata=main_metadata)
OtherBase = declarative_base(metadata=other_metadata)

class MainUser(MainBase):
    __tablename__ = 'User'
    __table_args__ = {schema : 'main'}

    id = sa.Column(Integer, primary_key=True, autoincrement=False)
    name = sa.Column(String(16))

class OtherUser(OtherBase):
    __tablename__ = 'User'
    __table_args__ = {schema : 'other'}

    id = sa.Column(Integer, primary_key=True, autoincrement=False)
    name = sa.Column(String(16))

This has a severe problem having to hard set the schema when that
value should be part of configuration. Instead the table should assume
the schema of the engine that it's metadata is bound to and
automatically appear in queries where there is a table from a
different schema than the one the query is being ran through.

In the mean time I'm just setting the schema on all the tables after
they are all defined and loaded:

for item in main_metadata.sorted_tables:
    item.schema = 'main'

for item in other_metadata.sorted_tables:
    item.schema = 'other'

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to