Re: [sqlalchemy] Tutorial/Example Code

2012-05-22 Thread Michael Bayer
A better idea, still thinking about it, just using __mapper_cls__ to intercept when the mapping is about to be created.This is probably the most appropriate place for this to happen - as the Table is being sent right to mapper(), we can respond to the Table and add more things to the propert

Re: [sqlalchemy] Tutorial/Example Code

2012-05-22 Thread Michael Bayer
On May 22, 2012, at 7:28 PM, David Bowser wrote: > The main advantage of example provided over the one in the documentation is > that it's more generic. The examples in SQLAlchemy are purposely not generic for two reasons. One is to minimize complexity and maintain the focus on usage of the

Re: [sqlalchemy] Removing relations with Many To One

2012-05-22 Thread Michael Wilson
Worked perfectly. Thanks! On May 23, 2012, at 12:10 AM, ThereMichael wrote: I have this relation: # Users user_table = Table('user', self.metadata, Column('id', Integer, primary_key=True), Column('place_id', Integer), mysql_engine='InnoDB' ) # Places

Re: [sqlalchemy] Removing relations with Many To One

2012-05-22 Thread Michael Bayer
On May 23, 2012, at 12:10 AM, ThereMichael wrote: > I have this relation: > > # Users > user_table = Table('user', self.metadata, > Column('id', Integer, primary_key=True), > Column('place_id', Integer), > mysql_engine='InnoDB' > ) > > # Places >

[sqlalchemy] Removing relations with Many To One

2012-05-22 Thread Michael Wilson
Hi All, I have this relation: # Users user_table = Table('user', self.metadata, Column('id', Integer, primary_key=True), Column('place_id', Integer), mysql_engine='InnoDB' ) # Places places_table = Table('places', self.metadata, Column('id', Int

[sqlalchemy] Removing relations with Many To One

2012-05-22 Thread ThereMichael
I have this relation: # Users user_table = Table('user', self.metadata, Column('id', Integer, primary_key=True), Column('place_id', Integer), mysql_engine='InnoDB' ) # Places places_table = Table('places', self.metadata, Column('id', Integer,

Re: [sqlalchemy] Tutorial/Example Code

2012-05-22 Thread David Bowser
The main advantage of example provided over the one in the documentation is that it's more generic. It doesn't require hardcoding anything about the class that being used with the mixin. It works equally well with composite keys, different types of primary key columns, or keys with different n

Re: [sqlalchemy] Tutorial/Example Code

2012-05-22 Thread Michael Bayer
The essence of this example from a SQLAlchemy mapping perspective is included in the SQLalchemy distro in the examples/generic_associations - there's three examples of how to build generic associations to a related object there.I'm not sure you need the "instrument_class" event here, you sh

Re: [sqlalchemy] Foreign key reflection error?

2012-05-22 Thread Demitri Muna
Hi, On May 22, 2012, at 5:03 PM, Michael Bayer wrote: > Did a quick experiment, and it appears that a ROLLBACK resets the search > path. Try calling dbapi_con.commit() in your event handler, that appears > to cause the search path to remain persistent for the life of that > connection.

Re: [sqlalchemy] Foreign key reflection error?

2012-05-22 Thread Michael Bayer
Did a quick experiment, and it appears that a ROLLBACK resets the search path. Try calling dbapi_con.commit() in your event handler, that appears to cause the search path to remain persistent for the life of that connection. On May 22, 2012, at 4:31 PM, Demitri Muna wrote: > Hi, > > Pr

Re: [sqlalchemy] Foreign key reflection error?

2012-05-22 Thread Demitri Muna
Where in my last email "three statements" = "five statements"... Sigh. -- 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+un

Re: [sqlalchemy] Foreign key reflection error?

2012-05-22 Thread Demitri Muna
Hi, Progress! But still not working 100%. I have three assert statements: one that tests a "to one" relationship across schemas, one that test a "to one" relationship within the same scheme, and two that test a "many to many" relationship across schemas (one assert for each direction). When I

[sqlalchemy] Tutorial/Example Code

2012-05-22 Thread David Bowser
Hi, I had a lot of trouble finding a decent set of examples on how to write a mixin that creates a class/table derived from a class. I've finally come up with a pattern that I'm pretty happy with an seems to fit most use cases that I saw when I was googling. I extracted, simplified, and commen