[sqlalchemy] Re: ForeignKey schema and Table schema

2009-05-08 Thread Aculeus

Sorry, I missed an example in my first message. The problem arises
when you try to query across two databases:

Session.query(MainUser).join((OtherUser, OtherUser.id == MainUser.id))

Would normally products something like:

SELECT * FROM MainUser INNER JOIN OtherUser ON OtherUser.id =
MainUser.id

When you really need the schema for the table that is in the other
database:


SELECT * FROM MainUser INNER JOIN other.OtherUser ON OtherUser.id =
MainUser.id

On May 7, 9:46 am, Michael Bayer mike...@zzzcomputing.com wrote:
 Aculeus wrote:

  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.

 if your engine() connects using a certain schema as the default schema,
 then no explicit schema argument is necessary for tables that are
 accessed by that engine within that schema.  schema is only used when
 accessing a non-default schema from a single engine.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: ForeignKey schema and Table schema

2009-05-08 Thread Michael Bayer

Aculeus wrote:

 Sorry, I missed an example in my first message. The problem arises
 when you try to query across two databases:

 Session.query(MainUser).join((OtherUser, OtherUser.id == MainUser.id))

 Would normally products something like:

 SELECT * FROM MainUser INNER JOIN OtherUser ON OtherUser.id =
 MainUser.id

 When you really need the schema for the table that is in the other
 database:


 SELECT * FROM MainUser INNER JOIN other.OtherUser ON OtherUser.id =
 MainUser.id

If i understand correctly, you'd like a single Table object to
dynamically change its schema based on which engine its used with.  The
only way to achieve something like this is to make a copy of the table
against a different schema using table.tometadata(someothermetadata,
schema='someschema').

Tables do not assume to be associated with any one engine, so your
feature request of the Table automatically setting its schema to the
default schema of some particular engine is not possible.  If you'd like
to achieve this yourself, create a Table function of your own:

def Table(*args, **kw):
   kw['schema'] = someschema
   return sqlalchemy.schema.Table(*args, **kw)



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: ForeignKey schema and Table schema

2009-05-07 Thread Michael Bayer

Aculeus wrote:


 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.

if your engine() connects using a certain schema as the default schema,
then no explicit schema argument is necessary for tables that are
accessed by that engine within that schema.  schema is only used when
accessing a non-default schema from a single engine.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---