[sqlalchemy] order of execution with MapperExtension

2008-05-23 Thread Moshe C.
I have a mapper created with a mapper extension that has an after_update() override. For a table in the mapper I do an update and then a commit(). This is the resulting order of execution: update instance (setting an attribute on the mapped class) commit after_update called on instance I.e.

[sqlalchemy] Re: order of execution with MapperExtension

2008-05-23 Thread Moshe C.
PLEASE IGNORE PREVIOUS. It turns out that explicitly flushing does change the order (made a silly coding error before). I am all set, but the question remains why autoflush isn't enough. On May 23, 2:15 pm, Moshe C. [EMAIL PROTECTED] wrote: I have a mapper created with a mapper extension that

[sqlalchemy] Re: Direct execute of postgres COPY

2008-05-23 Thread Michael Bayer
On May 23, 2008, at 2:49 AM, schickb wrote: On May 22, 8:37 pm, schickb [EMAIL PROTECTED] wrote: Maybe SA is putting second execute in a transaction that isn't being commited? That was the problem. I found this in the SA docs: While many DBAPIs implement a flag called autocommit, the

[sqlalchemy] Re: order of execution with MapperExtension

2008-05-23 Thread Michael Bayer
On May 23, 2008, at 7:26 AM, Moshe C. wrote: PLEASE IGNORE PREVIOUS. It turns out that explicitly flushing does change the order (made a silly coding error before). I am all set, but the question remains why autoflush isn't enough. autoflush will occur before every query execute and

[sqlalchemy] Re: order of execution with MapperExtension

2008-05-23 Thread Moshe Cohen
Evidently, when the autoflush occurred within the commit(), the database transaction COMMIT itself happened before the call to after_update() . The fact is that explicitly calling session.flush() immediately before calling session.commit(), changed the final state of the DB. This means the

[sqlalchemy] Re: order of execution with MapperExtension

2008-05-23 Thread Michael Bayer
On May 23, 2008, at 10:44 AM, Moshe Cohen wrote: Evidently, when the autoflush occurred within the commit(), the database transaction COMMIT itself happened before the call to after_update() . thats not how it works. the steps are: session.commit() session.flush()

[sqlalchemy] Re: mySQL force index?

2008-05-23 Thread jason kirtland
Geoff wrote: Does SQLA have any mechanism to use FORCE INDEX? Not in generated SQL. There is a ticket to add hinting support, but currently you'd need to use text() selects or join conditions to get the hints in. http://www.sqlalchemy.org/trac/ticket/921

[sqlalchemy] Problems with Oracle Express/sqlalchemy

2008-05-23 Thread Brandon Goldfedder
All, Perhaps someone can help me here since I am in that 'bad place' where I am retrying things again and getting deeper than I want into it. I am trying to create a database (using elixir model although the problem appears to be in sqlalchemy so asking here) in Oracle Express. The problem I

[sqlalchemy] Re: Problems with Oracle Express/sqlalchemy

2008-05-23 Thread Brandon Goldfedder
All, So have a 'working' solution but think it is pretty bad... Someone MUST have a better solution. Here is what I had to do: 1. Have create_all explictly not test for tables existing (or else it finds it in wrong schema) create_all(checkfirst = False) 2. Explictly set the schema and owner

[sqlalchemy] Counts that depend on joins

2008-05-23 Thread Justin Tulloss
Hello, I am doing a A-B join before I do any filtering on a query object constructed from A. I then to filtering based on C. I have a column_property mapped to A that gives me the total number of B. This is executed as a subquery, which means it gives me the total number of B in the database,

[sqlalchemy] Re: Counts that depend on joins

2008-05-23 Thread Justin Tulloss
On May 23, 4:33 pm, Justin Tulloss [EMAIL PROTECTED] wrote: I am doing a A-B join before I do any filtering on a query object Sorry, this should be A-B-C join. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: order of execution with MapperExtension

2008-05-23 Thread Moshe C.
I traced what is happening in the code. I don't fully understand it but I hope the following will help. The crucial point is that in my after_update() method I create a mapped object and call session.save() using the same session (but different table). This is the sequence of events: - I call

[sqlalchemy] Select results to object help

2008-05-23 Thread Jeff Putsch
Howdy, I'm a newbie to sqlalchemy and am having trouble understanding how to turn selects into objects. I've got two tables mapped into objects like this: nis_accounts_table = Table( ... ) nis_users_table = Table( ... ) class NisAccount: pass class NisUser: pass mapper(NisUser,

[sqlalchemy] Re: order of execution with MapperExtension

2008-05-23 Thread Michael Bayer
On May 23, 2008, at 6:54 PM, Moshe C. wrote: I traced what is happening in the code. I don't fully understand it but I hope the following will help. The crucial point is that in my after_update() method I create a mapped object and call session.save() using the same session (but

[sqlalchemy] Re: Problems with Oracle Express/sqlalchemy

2008-05-23 Thread Michael Bayer
On May 23, 2008, at 3:10 PM, Brandon Goldfedder wrote: All, Perhaps someone can help me here since I am in that 'bad place' where I am retrying things again and getting deeper than I want into it. I am trying to create a database (using elixir model although the problem appears to be in

[sqlalchemy] Re: Counts that depend on joins

2008-05-23 Thread Michael Bayer
On May 23, 2008, at 5:33 PM, Justin Tulloss wrote: Hello, I am doing a A-B join before I do any filtering on a query object constructed from A. I then to filtering based on C. I have a column_property mapped to A that gives me the total number of B. This is executed as a subquery, which

[sqlalchemy] Re: Select results to object help

2008-05-23 Thread Michael Bayer
On May 23, 2008, at 7:42 PM, Jeff Putsch wrote: Howdy, I'm a newbie to sqlalchemy and am having trouble understanding how to turn selects into objects. I've got two tables mapped into objects like this: nis_accounts_table = Table( ... ) nis_users_table = Table( ... ) class

[sqlalchemy] Re: order of execution with MapperExtension

2008-05-23 Thread Moshe C.
OK, thanks very much. My wrong assumption was that saves within the hook functions will make it into the current flush. Preceding the commit() with a manual flush, causes the commit to flush this new saves (that occured in the flush). Makes sense now :-) On May 24, 2:52 am, Michael Bayer

[sqlalchemy] Re: Problems with Oracle Express/sqlalchemy

2008-05-23 Thread Brandon Goldfedder
Michael, Yes - that is what I am doing now : ForeignKey(schemaname.tablename.colname) and I have things working. (see example 3). My problem is these steps seem really ugly and a lot more work than it should be to get things working portably and reliably - thus my question on if this is best

[sqlalchemy] Re: Select results to object help

2008-05-23 Thread Jeff Putsch
On May 23, 2008, at 5:07 PM, Michael Bayer wrote: Jeff Putsch wrote: Then I define some selects and execute them: s = select([nis_accounts_table, nis_users_table], from_obj=[nis_accounts_table.join(nis_users_table)]).where( nis_users_table.c.eid != '' )