[sqlalchemy] Create tables within a transaction

2009-02-05 Thread Chris Miles
I notice that a table create (and drop/etc) is always followed by an implicit commit. Is it possible to suppress the commit or force SA to create multiple tables in one transaction so that if any fail they can all be rolled back? Here's some code to demonstrate what I want. In this example,

[sqlalchemy] Re: Create tables within a transaction

2009-02-05 Thread Michael Bayer
create() and create_all() take a bind argument which can be an engine or connection. you want the connection in this case. On Feb 5, 2009, at 5:27 AM, Chris Miles wrote: I notice that a table create (and drop/etc) is always followed by an implicit commit. Is it possible to suppress the

[sqlalchemy] Re: Error: attribute refresh operation cannot proceed

2009-02-05 Thread Michael Bayer
On Feb 5, 2009, at 9:04 AM, pwaern wrote: What I would like to be able to is to keep on working with detached objects like the user object in the code above , in a manner where the objects attribute values are the same as they were when the session was closed, i.e. without further database

[sqlalchemy] Can polymorphic_identity be a range of values ?

2009-02-05 Thread Toby Bradshaw
Hi, So I (think I) understand that that polymorphic_on and polymorphic_identity can be used to determine which class is instantiated for a query result row. Is there any way I can use a range of values for polymorphic_identity to map to the same class ? Of specific interest to me right now

[sqlalchemy] Re: Can polymorphic_identity be a range of values ?

2009-02-05 Thread Michael Bayer
polymorphic_identity is intended to link to the class of an entity in a one-to-one fashion, so using a date type for this column would not be an appropriate usage.We have eventual plans to support polymorphic_identity supplied by a function but that feature is currently not

[sqlalchemy] Missing UPDATE on Parent

2009-02-05 Thread Massimo Bonvicini
Hi guys, I managed to model a device scanner based on SA 0.5.2. Everything works fine on the first run, but when i rerun a scan to refresh data (specially Client.scantime) i do not see any UPDATE statement called on clients table. What's wrong with my design? Thanks in advance Massimo Follow

[sqlalchemy] Re: Outer joins with ORM and single table polymorphism

2009-02-05 Thread MikeCo
After some experimenting I am able to generate the correct query by two methods (1) build query from ORM classes with ORM session.query() (2) build query from underlying tables with sql expressions I like the ORM based method better, because the code does not need to know which columns

[sqlalchemy] Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Gloria W
Hi All, I have three classes, all using the same declarative_base() instance, as follows: In a config file: global Base Base = None def initBase(): global Base if not Base: Base = declarative_base() return Base

[sqlalchemy] Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Gloria W
Hi All, I have three classes, all using the same declarative_base() instance, as follows: In a config file: global Base Base = None def initBase(): global Base if not Base: Base = declarative_base() return Base

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Michael Bayer
you're ordering the Member and Gender relation()s by a column in the parent table, which is producing the error.The order_by expression should be local to the Member or Gender entity. On Feb 5, 2009, at 11:54 AM, Gloria W wrote: Hi All, I have three classes, all using the same

[sqlalchemy] Re: cpython jdbc

2009-02-05 Thread Rick Morrison
I was wondering if anyone was aware of a JDBC DBAPI module for cpython. Interesting idea, and could be a killer feature for SA 0.6+ if it could be made to work Jpype could perhaps do the job: http://jpype.sourceforge.net/ There's been at least some activity with accessing JDBC drivers from

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Gloria W
Wow, awesome, it works, thank you! ~G~ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Gloria W
OK, a new problem on the same model: I try this in my unit test: memberProfile = self.session.query(MemberProfile).filter (MemberProfile.memberID.in_(memberid)).order_by (MemberProfile.memberID).filter(MemberProfile.city == 'Jamaica').all() and I get this error: Traceback (most recent call

[sqlalchemy] Re: Create tables within a transaction

2009-02-05 Thread Chris Miles
That did the trick, thanks. Well, actually, it did the trick for PostgreSQL but sqlite isn't rolling back. The SA logs show the same commands are being sent to both. Here's an example: $ rm test1.sqlite $ python sa_create_table_transaction_test.py 2009-02-06 13:39:29,006 INFO

[sqlalchemy] Re: Create tables within a transaction

2009-02-05 Thread Michael Bayer
sqlite doesn't include CREATE TABLE statements within the scope of a transaction. I think that's a relatively rare behavior only seen in Postgres, in fact - I dont think Oracle or MySQL have that behavior, for example. On Feb 5, 2009, at 10:01 PM, Chris Miles wrote: That did the trick,

[sqlalchemy] Re: Create tables within a transaction

2009-02-05 Thread Chris Miles
Ok. I'll do some testing against other engines when I get a chance. Thanks for helping. Cheers Chris Miles On Feb 6, 2:36 pm, Michael Bayer mike...@zzzcomputing.com wrote: sqlite doesn't include CREATE TABLE statements within the scope of a   transaction.  I think that's a relatively rare