[sqlalchemy] Re: last_inserted_ids and ORM

2009-05-07 Thread Mike Conley
Ahh yes, I use autoflush almost exclusively and forget that you can separate the flush() and commit(). -- Mike Conley On Tue, May 5, 2009 at 6:31 PM, Michael Bayer wrote: > > Mike Conley wrote: > > Does the idea of last_inserted_ids exist for ORM? > > > > I do > > session.add(someobj) >

[sqlalchemy] Re: last_inserted_ids and ORM

2009-05-05 Thread Michael Bayer
Mike Conley wrote: > Does the idea of last_inserted_ids exist for ORM? > > I do > session.add(someobj) > session.commit() > and then want the id of the newly inserted object. > > I can reference > someobj.id > but this generates a select call to the database get the id before yo

[sqlalchemy] Re: last_inserted_ids()

2007-07-09 Thread mc
Thanks On Jul 9, 7:44 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Jul 9, 2007, at 3:40 AM, mc wrote: > > > > > I have a followup question: > > > You posted above a function for retrieving the values by using another > > select query. > > The fact is that regardless of the differences betwee

[sqlalchemy] Re: last_inserted_ids()

2007-07-09 Thread Lele Gaifax
> > could i make the sqlalchemy subdirectory updateable by svn, or > > should i > > re-egg the updated package after every significant change? > > > > setuptools has a notion of PYTHONPATH thats not compatible with > Python's notion of itits usually easiest to "python setup.py" on > wha

[sqlalchemy] Re: last_inserted_ids()

2007-07-09 Thread Michael Bayer
On Jul 9, 2007, at 8:55 AM, alex bodnaru wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > hi mike, > > i have installed the 0.3.9 from svn, and now it's returning the > primary > key values of the last inserted record, as documented, even if > those are > not numeric. > > tha

[sqlalchemy] Re: last_inserted_ids()

2007-07-09 Thread Michael Bayer
On Jul 9, 2007, at 3:40 AM, mc wrote: > > I have a followup question: > > You posted above a function for retrieving the values by using another > select query. > The fact is that regardless of the differences between SQLalchemy > 0.3.6 to 0.3.9, MySQL returns the value of the non-primary-key >

[sqlalchemy] Re: last_inserted_ids()

2007-07-09 Thread alex bodnaru
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hi mike, i have installed the 0.3.9 from svn, and now it's returning the primary key values of the last inserted record, as documented, even if those are not numeric. thanks a lot! though i'm on a well packaged debian system, i have a lib deirecto

[sqlalchemy] Re: last_inserted_ids()

2007-07-09 Thread mc
I have a followup question: You posted above a function for retrieving the values by using another select query. The fact is that regardless of the differences between SQLalchemy 0.3.6 to 0.3.9, MySQL returns the value of the non-primary-key autoincrement column, otherwise 0.3.6 would not have th

[sqlalchemy] Re: last_inserted_ids()

2007-07-08 Thread mc
Too bad :-) Saves me a query. Thanks On Jul 8, 11:41 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > right. like ive been saying all along, this bug is fixed in trunk and > will be out in 0.3.9. > > On Jul 8, 2007, at 11:52 AM, mc wrote: > > > from sqlalchemy import * > > db=create_engine('mysql:

[sqlalchemy] Re: last_inserted_ids()

2007-07-08 Thread Michael Bayer
right. like ive been saying all along, this bug is fixed in trunk and will be out in 0.3.9. On Jul 8, 2007, at 11:52 AM, mc wrote: > from sqlalchemy import * > db=create_engine('mysql://user1:[EMAIL PROTECTED]/tests') > > create_s = """ > CREATE TABLE `users` ( > `user_name` varchar(16) NOT NU

[sqlalchemy] Re: last_inserted_ids() not initialized and not an attribute problem

2007-07-08 Thread Michael Bayer
On Jul 8, 2007, at 3:32 PM, SamDonaldson wrote: > > Hello, > > I'm having trouble with the last_inserted_ids() function. I'm running > an insert sql string as opposed to using the built in function. I > thought I should be getting a resultproxy back and then I should be > able to apply the las

[sqlalchemy] Re: last_inserted_ids()

2007-07-08 Thread Michael Bayer
On Jul 8, 2007, at 2:59 PM, alex bodnaru wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > hello, > > i was following this thread with interest, and found that > last_inserted_ids returns the oid of the inserted record. > > can i portably retrieve a record by this oid? > no. it

[sqlalchemy] Re: last_inserted_ids()

2007-07-08 Thread alex bodnaru
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hello, i was following this thread with interest, and found that last_inserted_ids returns the oid of the inserted record. can i portably retrieve a record by this oid? alex mc wrote: > here is a working script, (need to change connection paramet

[sqlalchemy] Re: last_inserted_ids()

2007-07-08 Thread mc
here is a working script, (need to change connection parameters , of course). When I run it the output is: [1L] [2L] Excpected according to documentation: ['Jack'] ['Jill'] ### from sqlalchemy import * db=create_engine('mysql://user1:[EMAIL PROTECTED]/tests') create_s = """ CREATE TABLE `users

[sqlalchemy] Re: last_inserted_ids()

2007-07-06 Thread Michael Bayer
On Jul 6, 4:33 am, mc <[EMAIL PROTECTED]> wrote: > I am using 0.3.6 and reading the 0.3 doc. > > The problem is that actually I need it the way it works for me now, > i.e. returning the auto_increment fields and not my primary key > fields. > Will upgrading sqlalchemy break this (undocumented)

[sqlalchemy] Re: last_inserted_ids()

2007-07-06 Thread Michael Bayer
On Jul 6, 2007, at 4:33 AM, mc wrote: > > I am using 0.3.6 and reading the 0.3 doc. > > The problem is that actually I need it the way it works for me now, > i.e. returning the auto_increment fields and not my primary key > fields. > Will upgrading sqlalchemy break this (undocumented) feature?

[sqlalchemy] Re: last_inserted_ids()

2007-07-06 Thread mc
I am using 0.3.6 and reading the 0.3 doc. The problem is that actually I need it the way it works for me now, i.e. returning the auto_increment fields and not my primary key fields. Will upgrading sqlalchemy break this (undocumented) feature? On Jul 4, 12:58 am, Michael Bayer <[EMAIL PROTECTED]

[sqlalchemy] Re: last_inserted_ids()

2007-07-03 Thread Michael Bayer
On Jul 3, 4:01 pm, mc <[EMAIL PROTECTED]> wrote: > What is the correct documentation for it? > The docs say it returns the primary key but for now I see it returns > an auto increment field (which is not part of the key). I doubt thats true. but also, this function has been reworked to be a lo

[sqlalchemy] Re: last_inserted_ids()

2007-07-03 Thread Alaa Salman
I believe that the documentation is quite clear last time i saw it. Last time i used it, if there is an incremented key, then it would return that. But it does not return simply any primary key. Someone correct me if i am wrong. Regards, Alaa Salman On 7/3/07, mc <[EMAIL PROTECTED]> wrote: > >