[sqlalchemy] Re: How to diagnose a transaction hang problem?

2010-01-30 Thread 一首诗
Your advice sound reasonable. That means I have check the transaction **before** the hanged commit, maybe I forgot to commit or close a session at that time. On Jan 31, 7:55 am, Gunnlaugur Briem wrote: > You probably don't have to add locks in your code. The database system > takes locks on beha

[sqlalchemy] passive updates and concurrent mod error

2010-01-30 Thread avdd
Something a bit more normal now. Combining optimistic concurrency control with cascading PK updates is problematic, if you load the child relation, the session issues unecessary updates for the children, resulting in ConcurrentModificationError """ import sqlalchemy as sql from sqlalchemy import

[sqlalchemy] Re: session.add() vs session.merge() and delete child

2010-01-30 Thread avdd
On Jan 31, 4:33 am, Michael Bayer wrote: > this example is too compliated for me to understand without great effort, > perhaps someone else has the time to follow it more closely - it appears to > be creating and closing many new sessions and add()ing objects between them - > an unusual series

[sqlalchemy] A portable way of resetting sequences?

2010-01-30 Thread Vinay Sajip
Is there a portable way of resetting sequences on platforms where they are used? I am initializing tables (for unit tests) - which have an autoincrementing id column as primary key - by uploading data from fixture files on disk into a database. On SQLite everything works fine, but on Postgres the s

[sqlalchemy] Re: MPTT

2010-01-30 Thread Gunnlaugur Briem
Yes, you can map a class against an arbitrary select, not just a table, see: http://www.sqlalchemy.org/docs/mappers.html#mapping-a-class-against-arbitrary-selects So above you have a query that you could map a class against (you might want to add the other nested_category columns to it). No need

[sqlalchemy] Re: How to diagnose a transaction hang problem?

2010-01-30 Thread Gunnlaugur Briem
You probably don't have to add locks in your code. The database system takes locks on behalf of your code (in operations initiated by your code) as necessary to ensure transactional consistency. That's one of the benefits of an RDBMS. What you do have to do is to make sure that those database lock

Re: [sqlalchemy] Re: inequivalent SQL statements for use_ansi=True vs. use_ansi=False

2010-01-30 Thread Michael Bayer
glad it works, like I said it wasn't a well attended-to feature so the basic issue was fairly obvious. Just not sure if it takes more elaborate contingencies into account. On Jan 30, 2010, at 5:29 PM, Kent wrote: > Wow. > > I am very impressed. The patch seems to have fixed this... I'll

[sqlalchemy] Re: inequivalent SQL statements for use_ansi=True vs. use_ansi=False

2010-01-30 Thread Kent
Wow. I am very impressed. The patch seems to have fixed this... I'll inspect it closer later to make sure it all looks correct. That was very fast. Thanks for taking the time even on a Saturday for this. I'm amazed at how fast you responded and fixed that. Thanks, Kent On Jan 30, 2:03 pm,

Re: [sqlalchemy] inequivalent SQL statements for use_ansi=True vs. use_ansi=False

2010-01-30 Thread Michael Bayer
On Jan 30, 2010, at 1:05 PM, Kent wrote: > While its certainly possible I've done something that isn't designed > for, I am getting inequivalent SQL statements when I flip to > use_ansi=False (unfortunately, I need to support oracle 8i). I've committed a fix in r6712 which changes how the traver

Re: [sqlalchemy] session.add() vs session.merge() and delete child

2010-01-30 Thread Michael Bayer
On Jan 30, 2010, at 9:07 AM, avdd wrote: > I'm using session.add() to refresh my objects while working on them, > because I don't want to merge them with the persistent state. But it > appears deletes aren't carrying across to child relations: in r6711 the save-update cascade operation will cas

Re: [sqlalchemy] inequivalent SQL statements for use_ansi=True vs. use_ansi=False

2010-01-30 Thread Michael Bayer
On Jan 30, 2010, at 1:05 PM, Kent wrote: > > p__a, od__a, p__b, and od__b are aliases I've defined in order to work > out this fairly complex query > > These joined aliases are being added to several of the outer selects > where I didn't intend for them. This is causing a cartesian product > a

[sqlalchemy] inequivalent SQL statements for use_ansi=True vs. use_ansi=False

2010-01-30 Thread Kent
While its certainly possible I've done something that isn't designed for, I am getting inequivalent SQL statements when I flip to use_ansi=False (unfortunately, I need to support oracle 8i). I may try duplicating the problem with a more simple query so I can post the tables & mappers here. This i

Re: [sqlalchemy] session.add() vs session.merge() and delete child

2010-01-30 Thread Michael Bayer
On Jan 30, 2010, at 9:07 AM, avdd wrote: > I'm using session.add() to refresh my objects while working on them, > because I don't want to merge them with the persistent state. But it > appears deletes aren't carrying across to child relations: this example is too compliated for me to understand

Re: [sqlalchemy] Re: MPTT

2010-01-30 Thread Juan Dela Cruz
Wow great ;) It really works. Thanks. One more thing, is it possible to map this in a Model Class perhaps as a python @property name level and make it query-able? Like passing it to a filter clause e.g. nested_category.query.filter(nested_category.c.level=='3') On Sat, Jan 30, 2010 at 8:48 AM, G

[sqlalchemy] session.add() vs session.merge() and delete child

2010-01-30 Thread avdd
I'm using session.add() to refresh my objects while working on them, because I don't want to merge them with the persistent state. But it appears deletes aren't carrying across to child relations: $ cat listdelete.py; python listdelete.py import sqlalchemy as sql from sqlalchemy import orm from