Re: [sqlalchemy] Copying Between Databases - Can I modify part of a Composite Key?

2012-09-27 Thread Shawn Wheatley
the most idiomatic way to handle this is to merge the objects in: obj = session.merge(existing_object) this will emit a SELECT for the existing row, then copy the state of existing_object to an object located for that primary key, if found. It ensures that the correct choice of

Re: [sqlalchemy] Copying Between Databases - Can I modify part of a Composite Key?

2012-09-27 Thread Shawn Wheatley
On Thursday, September 27, 2012 9:21:57 AM UTC-4, Shawn Wheatley wrote: the most idiomatic way to handle this is to merge the objects in: obj = session.merge(existing_object) this will emit a SELECT for the existing row, then copy the state of existing_object to an object located

Re: [sqlalchemy] Copying Between Databases - Can I modify part of a Composite Key?

2012-09-27 Thread Shawn Wheatley
session.merge only looks at the primary key of the instance you are inserting (it pays no attention to unique constraints). In your example, the table contains a single row with PK (1, 1), and you are merging an instance with PK (1, 4). SA sees these as different, so it tries to INSERT

Re: [sqlalchemy] Copying Between Databases - Can I modify part of a Composite Key?

2012-09-27 Thread Shawn Wheatley
On Thursday, September 27, 2012 1:06:14 PM UTC-4, Shawn Wheatley wrote: session.merge only looks at the primary key of the instance you are inserting (it pays no attention to unique constraints). In your example, the table contains a single row with PK (1, 1), and you are merging an instance

[sqlalchemy] Re: Declarative Models: Can they be used with two databases and two schema names?

2012-06-07 Thread Shawn Wheatley
Fantastic, that event hack was just what I needed. I did have to change sub to replace on the statement, for any future readers, but that was a trivial change. Thanks Michael! Shawn On Wednesday, June 6, 2012 3:51:55 PM UTC-4, Shawn Wheatley wrote: Hi, I'm trying to use my declarative

[sqlalchemy] Declarative Models: Can they be used with two databases and two schema names?

2012-06-06 Thread Shawn Wheatley
Hi, I'm trying to use my declarative models to copy data from an Oracle database with a non-default schema name to a SQLite database (which has no schema name, or at least a default name that can't be changed). Copying from Oracle to Oracle has not been a problem for me, but Oracle to SQLite