[sqlalchemy] Circular dependency - Read only database

2014-01-31 Thread Nicola Palumbo
Hi All, I would like to get all tables of a database that I have read only access.The lines below raise CircularDependencyError: Circular dependency detected. Cycles: How can I get around this problem? Any idea? from sqlalchemy.schema import MetaData meta = MetaData()

[sqlalchemy] Savepoints and expiry

2014-01-31 Thread Wolfgang Schnerring
Hello list, pardon the innocent/dumb question: wouldn't it make sense to expire_all() on begin_nested() and rollback()? My concrete example goes like this: savepoint = session.begin_nested() session.delete(stuff) session.begin_nested() # Now, if I don't call session.expire_all() here,

Re: [sqlalchemy] Circular dependency - Read only database

2014-01-31 Thread Michael Bayer
if you are reflecting tables, and sorting them reveals that there are mutual dependent foreign keys (or some other kind of cycle), then the tables can’t be delivered in foreign key dependency order, there is no such ordering. when creating Table objects you can break such a cycle using the

Re: [sqlalchemy] PostgreSQL 9.1 on the horizon, cool new stuff

2014-01-31 Thread Michael Bayer
On Jan 30, 2014, at 9:52 PM, Lucas Taylor ltaylor.vo...@gmail.com wrote: Any notion of how one might instruct SQLAlchemy to (conditionally) create tables using UNLOGGED? I'd like to be able to modify the DDL for all CREATE TABLE statements under certain conditions (dialect=postgresql

[sqlalchemy] group_by and lazy=False relationship problem

2014-01-31 Thread Robert Tasarz
Hi, I'm almost sure this is a bug, but maybe I'm missing something obvious. I've tested it with Python 3.3, SQLAlchemy 0.9.1, PostgreSQL 9.3 and reduced the issue to the following code: #!/usr/bin/env python3 from sqlalchemy import * from sqlalchemy.orm import * from

[sqlalchemy] Re: group_by and lazy=False relationship problem

2014-01-31 Thread Jonathan Vanasco
i believe you need to be explicit on your group_by : group_by(P.id) or group_by(P.attrs) or group_by(P.id,P.attrs) -- 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,

Re: [sqlalchemy] group_by and lazy=False relationship problem

2014-01-31 Thread Michael Bayer
On Jan 31, 2014, at 2:49 PM, Robert Tasarz robert.tas...@gmail.com wrote: Hi, I'm almost sure this is a bug, but maybe I'm missing something obvious. I've tested it with Python 3.3, SQLAlchemy 0.9.1, PostgreSQL 9.3 and reduced the issue to the following code: Here's most relevant

[sqlalchemy] Relationships using max

2014-01-31 Thread Josh Kuhn
I've got a two tables I'd like to create a relationship for. One is the object, and another tracks versions. Here's a gist with the setup: https://gist.github.com/deontologician/8744532 Basically, the object doesn't have a direct reference to the current version stored in the table. Instead, the

Re: [sqlalchemy] PostgreSQL 9.1 on the horizon, cool new stuff

2014-01-31 Thread Lucas Taylor
On Friday, January 31, 2014 7:45:07 AM UTC-7, Michael Bayer wrote: On Jan 30, 2014, at 9:52 PM, Lucas Taylor ltaylo...@gmail.comjavascript: wrote: Any notion of how one might instruct SQLAlchemy to (conditionally) create tables using UNLOGGED? I'd like to be able to modify the DDL for

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-01-31 Thread Michael Bayer
On Jan 31, 2014, at 5:24 PM, lars van gemerden l...@rational-it.com wrote: Hi, all I am running into these 2 errors and have run out of ideas what to do about it (also because i don't what they mean); They seem to happen in exactly the same circumstances. mapper, table, update)

Re: [sqlalchemy] Relationships using max

2014-01-31 Thread Michael Bayer
well I can get it to work for lazy loading like this: expr = select([func.max(Version.id)]).\ where(Version.object_id == Object.id).\ correlate_except(Version).as_scalar() Object.current_version = relationship(Version, primaryjoin=and_(

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-01-31 Thread lars van gemerden
Hi Michael, With some more detail: What i do is: 1 make a new object (mapped)- obj1 2 create a scoped session (with context manager)- session1 3 do session1.add(obj) 4 create another scoped session - session2 5 do session2.query(someclass).get(some_id)-obj2 6 close session2, no commit, no

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-01-31 Thread Michael Bayer
On Jan 31, 2014, at 8:11 PM, lars van gemerden l...@rational-it.com wrote: this means an object was meant to be UPDATEed via the ORM, however the row which is the target of the UPDATE is missing. Either the primary key of this row changed somehow, or the row was deleted, *or* the row is

Re: [sqlalchemy] Relationships using max

2014-01-31 Thread Michael Bayer
On Jan 31, 2014, at 8:51 PM, Josh Kuhn deontologic...@gmail.com wrote: This is pretty amazing. I get it to *almost* work. The issue seems to be that I don't use the database column names as my model attribute names. The db column names are really obfuscated, so it's more like: class