[sqlalchemy] Re: Do the columns in 'foreign_keys' represent only the 'foreign' columns in this join condition ?

2009-10-16 Thread cd34
On Oct 17, 1:36 am, Michael Bayer wrote: > At the moment you have an and_() of two string expressions, which   > SQLalchemy knows nothing about and therefore cannot apply mapping   > logic to it.   When using declarative, you do have the option to quote   > the expression in the case that you'd

[sqlalchemy] Re: Do the columns in 'foreign_keys' represent only the 'foreign' columns in this join condition ?

2009-10-16 Thread Michael Bayer
On Oct 17, 2009, at 1:07 AM, cd34 wrote: > > When I add the second condition in the primaryjoin as: > >users = relation('cp_users', primaryjoin=and_ > ('cp_package_device.device_id > = > = > cp_users.device_id > ','cp_package_device.client_id==cp_users.client_id'),foreign_keys= > ['cp_users.

[sqlalchemy] Do the columns in 'foreign_keys' represent only the 'foreign' columns in this join condition ?

2009-10-16 Thread cd34
I'm using SQLAlchemy 0.5.6, Python 2.5.4, Debian Linux I have a defined schema but am experimenting with a different way to display the data. While I have gotten a portion of this working, I am stuck putting the second condition into the primaryjoin. Classes have been clipped for brevity. clas

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-16 Thread empty
On Oct 15, 11:50 pm, Jeff Cook wrote: > > So, SQLAlchemy is doing something here. There probably is some > incorrect code in my program, which is why I am writing this list, to > figure out what that is. I'm an experienced developer and I don't > appreciate your disrespect. I can follow tutorials

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-16 Thread Jeff Cook
Thanks for the help. I wasn't assigning the session to SQLSoup's session, but I am now, and I'm still getting stale data and I don't know yet if I'll still be getting the invalid transaction/MySQL has gone away thing. I think I'll try just taking SQLSoup out of the thing all together and try SQLAl

[sqlalchemy] Querying Against A Single Inheritance Structure

2009-10-16 Thread mgemmill
I'm sure this is something fairly basic, but I'm stumped at this point. I have a single table inheritance scheme setup very similar to this: class SimpleType(object): def __init__(self, type='base_type', name='base_type'): self.type = type self.name = name class AddressType(S

[sqlalchemy] large/fast inserts

2009-10-16 Thread strattonbrazil
I'm trying to setup fast insertions using sqlalchemy/sqlite and it seems to be taking an unnecessarily long amount of time to do many of the inserts. It looks like the main call that inserts into a few tables takes about 1-2 seconds each for the first few calls, but then drops down to around 50ms

[sqlalchemy] Re: backref vs. back_populate

2009-10-16 Thread fogathm...@googlemail.com
On Oct 16, 5:18 pm, "Michael Bayer" wrote: > fogathm...@googlemail.com wrote: > > > Ah, thanks, that makes sense. So I was wrong in assuming the two forms > > were equivalent - backref merely allows you to access a relation from > > the other side, whereas back_populates performs synchronizatio

[sqlalchemy] Re: backref vs. back_populate

2009-10-16 Thread Michael Bayer
fogathm...@googlemail.com wrote: > > Ah, thanks, that makes sense. So I was wrong in assuming the two forms > were equivalent - backref merely allows you to access a relation from > the other side, whereas back_populates performs synchronization on > both ends. OK, I will keep that in mind from no

[sqlalchemy] Re: backref vs. back_populate

2009-10-16 Thread fogathm...@googlemail.com
On Oct 16, 12:50 pm, Michael Bayer wrote: > On Oct 16, 2009, at 4:43 AM, fogathm...@googlemail.com wrote: > > > > > > > Hello! > > > From reading the docs, I assumed that using "backref" on the child's > > orm.relation declaration in a 1:n relationship is equivalent to using > > "back_populates

[sqlalchemy] Re: Modifying the scopefunc of an existing ScopedSession

2009-10-16 Thread Iwan
Hi Gaetan, On Oct 14, 5:11 pm, Gaetan de Menten wrote: > On Wed, Oct 14, 2009 at 17:09, Gaetan de Menten wrote: > > > Btw: Iwan, did you try: > > factory = elixir.session.session_factory > elixir.session.registry = sqlalchemy.util.ScopedRegistry(factory, > scope_func=your_scope_func) I gave up

[sqlalchemy] getting a numpy recarray from a sqlalchemy query

2009-10-16 Thread Giovanni Marco Dall'Olio
Hi, I think it would be cool to have an option to obtain the results of a sqlalchemy query as a numpy's recarray, instead of a list of tuples as it is now. Examples: >>> data = session.query(People.name, People.surname, People.apples, >>> People.pears).as_recarray() >>> data['name'] Albert Mari

[sqlalchemy] Re: backref vs. back_populate

2009-10-16 Thread Michael Bayer
On Oct 16, 2009, at 4:43 AM, fogathm...@googlemail.com wrote: > > Hello! > > From reading the docs, I assumed that using "backref" on the child's > orm.relation declaration in a 1:n relationship is equivalent to using > "back_populates" with explicit orm.relation declarations on both ends. > How

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-16 Thread Michael Bayer
On Oct 15, 2009, at 11:50 PM, Jeff Cook wrote: > > So, SQLAlchemy is doing something here. There probably is some > incorrect code in my program, which is why I am writing this list, to > figure out what that is. I'm an experienced developer and I don't > appreciate your disrespect. I can follow

[sqlalchemy] Re: What happens if a session is closed inside a subtransaction?

2009-10-16 Thread Oliver Beattie
I should probably ask something else too… how much overhead is there in using subtransactions as opposed to one "global" transaction? On Oct 14, 3:18 pm, "Michael Bayer" wrote: > Oliver Beattie wrote: > > > Hi All, > > > I'm just wondering what happens if I were to call session.close() > > whils

[sqlalchemy] Re: What happens if a session is closed inside a subtransaction?

2009-10-16 Thread Oliver Beattie
Thanks for your quick answer, Michael, that's really helpful. Sorry for the confusion surrounding subtransactions vs. SAVEPOINTs — I am indeed using subtransactions… just clearly haven't got the lingo down yet ;) Looking at my code now, I'm not too sure why I felt the need to call close() at all

[sqlalchemy] backref vs. back_populate

2009-10-16 Thread fogathm...@googlemail.com
Hello! >From reading the docs, I assumed that using "backref" on the child's orm.relation declaration in a 1:n relationship is equivalent to using "back_populates" with explicit orm.relation declarations on both ends. However, it turns out that I get double insertions when using back_populates -