[sqlalchemy] sqlalchemy failing to commit somewhere (but fails silently) when trying to update data

2013-03-18 Thread alonn
Like all CRUD goes, I need to write some data to a table. when I write new data to the table, everything works like charm. the problem starts when I need to write data already existing in the table (actually updating some data with the same primary key). the data just doesn't seem to be written

Re: [sqlalchemy] sqlalchemy failing to commit somewhere (but fails silently) when trying to update data

2013-03-18 Thread Michael Bayer
one thing to note is that deepcopy() is not going to work. It will copy SQLAlchemy's own accounting information on the object as well and generally cause confusion. The easiest way to insert a lot of data while detecting dupes efficiently is to sort the data, then chunk through it, and for

Re: [sqlalchemy] advices

2013-03-18 Thread Michael Bayer
On Mar 15, 2013, at 3:19 PM, Julien Cigar jci...@ulb.ac.be wrote: On 03/14/2013 19:56, Michael Bayer wrote: On Mar 12, 2013, at 5:13 AM, Julien Cigar jci...@ulb.ac.be wrote: Hello, I have written a CMS which is, among other, based on the joined load inheritance feature of SQLAlchemy.

Re: [sqlalchemy] Error during roll back

2013-03-18 Thread Michael Bayer
that's an old bug that's been fixed. 0.7.1 is ancient you should upgrade to 0.7.10. On Mar 17, 2013, at 1:38 AM, Warwick Prince warwi...@mushroomsys.com wrote: Hi Michael I have some fairly basic code which is moving data from one DB to another. I have trapped errors on inserts just

Re: [sqlalchemy] Error during roll back

2013-03-18 Thread Michael Bayer
specifically it occurs when you receive an exception on flush(), but then you keep doing things that change the state of the session before calling rollback(). here's the original test: http://www.sqlalchemy.org/trac/attachment/ticket/2389/sqlalchemy_rollback_bug.py On Mar 17, 2013, at 1:38

[sqlalchemy] column_property for correlated subquery

2013-03-18 Thread millerdev
Hi, Using declarative here, and I'm trying to create a column_property with a correlated subquery that returns a count of records with a matching value in some other column. Here's what I've tried. Option 1 is the best, option 2 is ugly but second best, option 3 is not a good option since

[sqlalchemy] Re: column_property for correlated subquery

2013-03-18 Thread millerdev
Forgot to add, I'm on SA 0.7.8 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to

Re: [sqlalchemy] column_property for correlated subquery

2013-03-18 Thread Michael Bayer
the typical hook for this kind of thing is __declare_last__, works after everything has been compiled. you might have an easier time also (or might not matter) if you build against the Table (i.e. Foo.__table__.alias(), etc.) instead of firing up the class with aliased(Foo), but if you're in

Re: [sqlalchemy] sqlalchemy failing to commit somewhere (but fails silently) when trying to update data

2013-03-18 Thread alonn
Thanks Michael for the good advice. since I don't this chunking solution won't work for this specific use case (The keys would be hard to sort) would't it be an easier solution just to move transaction.commit() after each flush, so the DBSession.rollback() wouldn't lose existing data in the

Re: [sqlalchemy] sqlalchemy failing to commit somewhere (but fails silently) when trying to update data

2013-03-18 Thread Michael Bayer
if you want to go that approach I suggest you use begin_nested() which will produce a SAVEPOINT, local to a certain scope within the transaction. you'll have better results with 0.8 using this approach. On Mar 18, 2013, at 1:54 PM, alonn alonis...@gmail.com wrote: Thanks Michael for the

[sqlalchemy] Advice: Best practice for working with an existing database

2013-03-18 Thread Peter Herndon
Hi all, I'm new to SQLAlchemy, and looking for some advice on how to approach working with an existing database. The database will not be managed by Python, and I will need to maintain whatever library I write to keep up with the occasional schema change. I am looking to write a more-or-less

Re: [sqlalchemy] Error during roll back

2013-03-18 Thread Warwick Prince
Cool - Thanks. Upgrade on the way.. :-) Cheers Warwick specifically it occurs when you receive an exception on flush(), but then you keep doing things that change the state of the session before calling rollback(). here's the original test:

[sqlalchemy] question about using SAVEPOINTS

2013-03-18 Thread alonn
from the docshttp://docs.sqlalchemy.org/en/latest/orm/session.html#using-savepoint : begin_nested()http://docs.sqlalchemy.org/en/latest/orm/session.html#sqlalchemy.orm.session.Session.begin_nested may be called any number of times, which will issue a new SAVEPOINT with a unique identifier for

[sqlalchemy] Re: column_property for correlated subquery

2013-03-18 Thread alonn
If I understand the problem correctly your best shot would be using sqlalchemy magical `hybrid_property` , hybrid_method, etc. here: http://docs.sqlalchemy.org/ru/latest/orm/extensions/hybrid.html On Monday, March 18, 2013 9:20:15 PM UTC+2, millerdev wrote: Hi, Using declarative here,

Re: [sqlalchemy] question about using SAVEPOINTS

2013-03-18 Thread Michael Bayer
On Mar 18, 2013, at 4:22 PM, alonn alonis...@gmail.com wrote: from the docs: begin_nested() may be called any number of times, which will issue a new SAVEPOINT with a unique identifier for each call. For each begin_nested() call, a corresponding rollback() or commit() must be issued.