[sqlalchemy] Re: detached, pickled sqlalchemy collection object failing after server restart

2009-10-22 Thread rootsmith
Well, it appears I have answered my own question and, yes, it was a SQLAlchemy issue. I resolved the problem by explicitly compiling the mapping at the end of the model initialization: manager_mapper = orm.mapper(Manager, manager_table, ... etc. ... (all other dependent mappers)

[sqlalchemy] Re: detached, pickled sqlalchemy collection object failing after server restart

2009-10-22 Thread Michael Bayer
rootsmith wrote: Well, it appears I have answered my own question and, yes, it was a SQLAlchemy issue. I resolved the problem by explicitly compiling the mapping at the end of the model initialization: manager_mapper = orm.mapper(Manager, manager_table, ... etc. ... (all other dependent

[sqlalchemy] not expected generated update query values

2009-10-22 Thread sector119
Hi All! Why I get at SET part not only items from values(...), but all from params passed to session.execute? transactions_update = model.transactions_table.update().where(and_(model.transactions_table.c.commit_date==bindparam('commit_date'),

[sqlalchemy] Re: not expected generated update query values

2009-10-22 Thread Michael Bayer
sector119 wrote: Hi All! Why I get at SET part not only items from values(...), but all from params passed to session.execute? transactions_update = model.transactions_table.update().where(and_(model.transactions_table.c.commit_date==bindparam('commit_date'),

[sqlalchemy] Re: not expected generated update query values

2009-10-22 Thread sector119
though likely cleaner to pass the exact set of parameters desired. How to pass that params if I use bindparam at where() and values(), but I don't want to update colums that are at where() clause, only at values() ? --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: not expected generated update query values

2009-10-22 Thread Michael Bayer
sector119 wrote: though likely cleaner to pass the exact set of parameters desired. How to pass that params if I use bindparam at where() and values(), but I don't want to update colums that are at where() clause, only at values() ? if you are using bindparam() objects, you'd given them

[sqlalchemy] Re: attempting something like a bulk insert ignore

2009-10-22 Thread Josh Stratton
you'd need to establish the primary key from the mapper's point of view in terms of both userId and userName.   mapper() accepts a primary_key argument for this purpose. That kind of surprises me sqlalchemy isn't aware of what's a primary key and what isn't. Looking at the docs, it states

[sqlalchemy] Re: attempting something like a bulk insert ignore

2009-10-22 Thread Michael Bayer
Josh Stratton wrote: I've tried this and primary_key=[usersTable.c.userId] and all the attributes contributing to the primary key and still see IntegrityErrors when inserting into the users table. class 'sqlalchemy.exceptions.IntegrityError': (IntegrityError) column userName is not unique

[sqlalchemy] Re: detached, pickled sqlalchemy collection object failing after server restart

2009-10-22 Thread rootsmith
Thanks for the compile_mappers() call - that is a lot easier than calling compile() on all the individual mappers. What is very strange is that I can see at the point of my first calling on the object from the beaker session, I retrieve it and merge it successfully into the SQLAlchemy Session.

[sqlalchemy] David Bolen on SA and Twisted

2009-10-22 Thread Don Dwiggins
I'm considering using the SA SQL expression facility in a Twisted server, replacing some SQL creation code that's vulnerable to SQL injection attacks. Doing some exploration on the intersection of Twisted and SA, I came across a message by David Bolen in February of 2007, describing a simple

[sqlalchemy] ResultProxy: nextset?

2009-10-22 Thread Don Dwiggins
I've started playing somewhat seriously with the SQL expression subset of SA as a replacement for some direct SQL code (and as a possible first step to heavier use of SA). As part of this, I took a query containing several selects, which naturally returns several result sets. In my current

[sqlalchemy] Re: not expected generated update query values

2009-10-22 Thread sector119
Something strange, Michael.. All bindparams are different. Compliller should not add to SET all params if values() has bindparam args, no? where() have: bindparam('commit_date'), bindparam('serial'), bindparam ('office_id') values() have: bindparam('rollback_date'),

[sqlalchemy] Re: ResultProxy: nextset?

2009-10-22 Thread Michael Bayer
Don Dwiggins wrote: I've started playing somewhat seriously with the SQL expression subset of SA as a replacement for some direct SQL code (and as a possible first step to heavier use of SA). As part of this, I took a query containing several selects, which naturally returns several result

[sqlalchemy] Re: not expected generated update query values

2009-10-22 Thread Michael Bayer
sector119 wrote: Something strange, Michael.. All bindparams are different. Compliller should not add to SET all params if values() has bindparam args, no? where() have: bindparam('commit_date'), bindparam('serial'), bindparam ('office_id') values() have:

[sqlalchemy] Re: David Bolen on SA and Twisted

2009-10-22 Thread David Bolen
Don Dwiggins d...@dondwiggins.net writes: Doing some exploration on the intersection of Twisted and SA, I came across a message by David Bolen in February of 2007, describing a simple database class that contained a background thread for execution. I'd like to know if that work, or some

[sqlalchemy] Re: attempting something like a bulk insert ignore

2009-10-22 Thread Josh Stratton
OK, you have the unique constraint on userName alone.  that means that you *cannot* have two rows like this: userId      userName 1           someuser 2           someuser Right. because unlike a primary key that consists of userId and userName, the distinctness here of userName is

[sqlalchemy] Re: attempting something like a bulk insert ignore

2009-10-22 Thread Michael Bayer
Josh Stratton wrote: Maybe my setup isn't correct, but if I do something like this: session.add(myObj) session.flush() # try adding to the database here # check if it's in there matches = [obj for obj in

[sqlalchemy] Custom ORM inserts and updates

2009-10-22 Thread Ian
Is there any way to customize the mapper-generated queries used for persisting objects? My specific case is that I would like to have the ORM call a stored procedure for inserts and updates rather than the usual insert and update statements. Thanks, Ian

[sqlalchemy] Re: Custom ORM inserts and updates

2009-10-22 Thread Michael Bayer
Ian wrote: Is there any way to customize the mapper-generated queries used for persisting objects? My specific case is that I would like to have the ORM call a stored procedure for inserts and updates rather than the usual insert and update statements. in a way that is transparent within

[sqlalchemy] Re: David Bolen on SA and Twisted

2009-10-22 Thread Don Dwiggins
David, thanks for the quick reply. Well, the server using it, in a slightly modified version from that message, remains in production, and has been continuously since July of 2007. So it's certainly worked for its intended purpose for me - that is, offloading the SA database I/O to a

[sqlalchemy] Re: Saved Queries (or text representation of the SQL)

2009-10-22 Thread Michael Bayer
On Oct 22, 2009, at 6:33 PM, jeff wrote: I would like to allow user's to save favorite queries in my Python app. Is there a way to find out the SQL statement as a string that can be then reused (e.g. Engine.execute(text(savedQueryText) ) )? Or is there another solution to this need?

[sqlalchemy] Re: not expected generated update query values

2009-10-22 Thread Michael Bayer
On Oct 22, 2009, at 3:26 PM, sector119 wrote: Something strange, Michael.. All bindparams are different. Compliller should not add to SET all params if values() has bindparam args, no? where() have: bindparam('commit_date'), bindparam('serial'), bindparam ('office_id') values() have: