Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-02-01 Thread lars van gemerden
Thanks, this helps some to narrow it down. Trying to zoom in: - why would sqla try to UPDATE (instead of INSERT) a row in the database, when the row/object was never committed before? - when you flush an object to the database and then close the session that flushed (no commit), what happens

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-02-01 Thread lars van gemerden
Oh, on more question: might there be anything inherently wrong with the scoped_session approach that i showed in the code snippets above? CL On Saturday, February 1, 2014 1:25:27 PM UTC+1, lars van gemerden wrote: Thanks, this helps some to narrow it down. Trying to zoom in: - why would

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

2014-02-01 Thread Robert Tasarz
On 01/31/2014 10:56 PM, Michael Bayer wrote: 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

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-02-01 Thread lars van gemerden
Ok, Michael, That helped a lot, what i have done is (for future reference/others); 1) turned of autoflush on all sessions, 2) shortened the lifespan of session to a minimum, 3) removed the if object_session(obj): session.merge(obj) option in the Session() function, This seems to have solved

[sqlalchemy] Using SQ with Django models

2014-02-01 Thread Michael Hipp
Hello, I have a database in PostgreSQL that is built and updated using Django 1.2 and I'd like to access it with SA. Are there any quick pointers you could offer to get me started on the best way to do that (e.g. duplicate Django's models.py in SA, use reflection, etc.)? The tables have a

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-01 Thread Michael Bayer
On Feb 1, 2014, at 11:50 AM, Adrian Robert adrian.b.rob...@gmail.com wrote: Hi, I'm new to sqlalchemy though I've used other ORMs (e.g. Hibernate) before, and I'm trying to use the new automap feature. However it seems to be using the foreign table name rather than a suffixed version

[sqlalchemy] Re: Using SQ with Django models

2014-02-01 Thread Jonathan Vanasco
Check out this project: https://pypi.python.org/pypi/sqlacodegen it's a replacement to sqlautocode the packages are designed to inspect your database and create sqlalchemy models ( in python code) for you. you'll have to edit/audit the generated code -- but it will save A LOT of time. --

[sqlalchemy] from_statement, TextAsFrom and stored procedures

2014-02-01 Thread Matthew Phipps
Hi SQLAlchemy, Our data team wants us to use a (SQL Server 2008 R2) stored procedure to perform our major query, which is all well and good, except it's preventing SQLAlchemy's type processing from being applied. This is on SQLAlchemy 0.9.1, using pyodbc and FreeTDS. For example, say we are