[sqlalchemy] SQLAlchemy 'prepared' state problem

2013-07-12 Thread yaroslav
I have a problem with SQL Alchemy 0.8.1 on Python 2.7 running on linux box via mod_wsgi. From time to time it produces the InvalidRequestError: This session is in 'prepared' state; no further SQL can be emitted within this transaction. I use mod_wsgi with multiple processes of 1 thread per

Re: [sqlalchemy] SQLAlchemy 'prepared' state problem

2013-07-12 Thread Michael Bayer
prepared state is an internal state in the Session which occurs within the transaction commit process. This error can occur in one of the following ways: 1. you have an after_commit() event handler which raised an exception, leaving the Session in the prepared state without being able to

Re: [sqlalchemy] Retreiving datetime(6) value using sqlalchemy

2013-07-12 Thread Michael Bayer
engine.execute(some string) doesn't know anything about what you are querying or what kind of data is in the result, it is a pure pass-through to the DBAPI, which is MySQL-Python by default here. So your issue is with mysql-python. Either upgrade it, report a bug to them, or use a different

[sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread lars van gemerden
Hi all, I had an arror in my code and i think i have reconstructed it as follows: --- from sqlalchemy import Column, Integer, String from sqlalchemy import create_engine from

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Michael Bayer
We've never supported del obj.attrname as a means of setting an attribute to None (which translates to NULL in SQL). Setting the value to None explicitly is preferred. On Jul 12, 2013, at 12:16 PM, lars van gemerden l...@rational-it.com wrote: Hi all, I had an arror in my code and i

[sqlalchemy] AbstractConcreteBase equivalent with classical mappings

2013-07-12 Thread Alexandre Torres
Hi, I have the following concrete inheritance structure (simplified in fact...) A -- B -- L1 A -- C -- L2 Where L1 and L2 have tables (T1, T2). using declarative, I could define classes A,B and C as AbstractConcreteBase, and therefore issue polymorphic queries including L1,L2 (and any other

Re: [sqlalchemy] AbstractConcreteBase equivalent with classical mappings

2013-07-12 Thread Michael Bayer
On Jul 12, 2013, at 12:49 PM, Alexandre Torres alexandre.tor...@gmail.com wrote: Hi, I have the following concrete inheritance structure (simplified in fact...) A -- B -- L1 A -- C -- L2 Where L1 and L2 have tables (T1, T2). using declarative, I could define classes A,B and C as

Re: [sqlalchemy] SQLAlchemy 'prepared' state problem

2013-07-12 Thread yaroslav
You nailed it down damn straight! For some reason mod_wsgi was indead configured to use threads instead of processes. Thanks a lot for the heads up! пятница, 12 июля 2013 г., 17:40:37 UTC+3 пользователь Michael Bayer написал: 2. you have concurrent access to the session such that one thread

[sqlalchemy] Re: AbstractConcreteBase equivalent with classical mappings

2013-07-12 Thread Alexandre Torres
Thank you Michael! It works very well! It just looks like the classical thing is going to be aborted. What gives you that impression? The entire ORM is built upon mapper(), that's the most fundamental feature of the whole library. Declarative is just an extension on top of it (hence its

[sqlalchemy] Multi Database Relationship With Primay Join (MSSQL)

2013-07-12 Thread Victor Reichert
Hello, I am attempting to implement a relationship accross two MSSQL databases that may or may not be on the samer server. The catch is that MSSQL does not support cross database forgien key contraints (the tables must be in the same db). I am trying to to implement the relationship with a

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Lars van Gemerden
Can i just override __delattr__ in a subclass of a declarative base to achieve this anyway? Cheers, Lars Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 12 jul. 2013, at 18:28, Michael Bayer

[sqlalchemy] PostGIS/SQLite DateTime

2013-07-12 Thread Basil Veerman
Hi, I've been struggling for a while trying to create a mapping that works with both PostGIS and SQLite databases when dealing with DateTime. Background: Production PostGIS database has been reduced and converted to a spatialite database with the same schema for offline testing purposes.

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Lars van Gemerden
After thinking on it some more, should InstrumentedAttribute.__delete__ even exist then, or maybe raise a NotImplementedError? CL Lars van Gemerden l...@rational-it.com +31 6 26 88 55 39 On 12 jul. 2013, at 18:28,

Re: [sqlalchemy] Generated update command is alway schosing alternative field names

2013-07-12 Thread Richard Gomes
I thought this could be of interest ot the mailing list: def select(self, table, index=None, *args, **kwargs): ''' Helper function which eases generation of SELECT statements using indexes. Arguments - table -- an instance of

[sqlalchemy] Query compilation cost

2013-07-12 Thread Amir Elaguizy
I'd like a way to avoid the cost of repeatedly compiling the same query, especially in the context of relationship caching. Specifically now that I have object caching in place, I have created my own keys where it is possible. However there are still some cases where I cannot. In these cases

Re: [sqlalchemy] Multi Database Relationship With Primay Join (MSSQL)

2013-07-12 Thread Michael Bayer
On Jul 12, 2013, at 5:35 PM, Victor Reichert vfr...@gmail.com wrote: Simulated_Events.sim = ServerName.Temp_DB.dbo.Simulation_Catalog_Table.Sims and Simulated_Events.event_id = ServerName.Temp_DB.dbo.Simulation_Catalog_Table.EventID ^ SyntaxError: invalid

Re: [sqlalchemy] PostGIS/SQLite DateTime

2013-07-12 Thread Michael Bayer
On Jul 12, 2013, at 5:53 PM, Basil Veerman bveer...@uvic.ca wrote: Hi, I've been struggling for a while trying to create a mapping that works with both PostGIS what's a PostGIS database? do you mean a Postgresql database with spatial extensions installed? Background: Production

Re: [sqlalchemy] possible bug in InstrumentedAttribute.__delete__?

2013-07-12 Thread Michael Bayer
There's all kinds of things that __delete__ should possibly do, most likely just do what you expect, i.e. set the value to NULL, but this would be changing its behavior in a very backwards-incompatible way; such a change could only be considered for 0.9. Whats not clear is how exactly an

Re: [sqlalchemy] Query compilation cost

2013-07-12 Thread Michael Bayer
On Jul 12, 2013, at 7:03 PM, Amir Elaguizy aelag...@gmail.com wrote: I'd like a way to avoid the cost of repeatedly compiling the same query, especially in the context of relationship caching. Specifically now that I have object caching in place, I have created my own keys where it is

Re: [sqlalchemy] PostGIS/SQLite DateTime

2013-07-12 Thread Basil Veerman
Here is a short example that illustrates the original error: *Create Test Database:* $ sqlite3 testing.sqlite SQLite version 3.7.13 2012-06-11 02:05:22 Enter .help for instructions Enter SQL statements terminated with a ; sqlite BEGIN TRANSACTION; sqlite CREATE TABLE 'obs_raw' ('obs_raw_id'

Re: [sqlalchemy] PostGIS/SQLite DateTime

2013-07-12 Thread Michael Bayer
Right, DateTime + with_variant() + sqlite.DATETIME with a custom storage format and regexp. *However*. There's an unfortunate case that the storage format/regexp arguments, introduced in 0.8.0, are not actually working fully, and I've just committed the fix. So you'll have to use 0.8.3 for

[sqlalchemy] Changing the declarative base of a class and re-mapping

2013-07-12 Thread Ahmed
Hello all, I have the following scenario: I have 5 or 6 related sqlalchemy declarative models sitting in a pyramid app. This occurs in the context of extending a pyramid application, where I import/config.scan() these selected models from another pyramid app into a new app. The thing is that