[sqlalchemy] Re: isolation level not supported on MySQL 3.23

2012-09-18 Thread Ids
Mmm. The traceback I got last (TypeError), only occurs on a client platform (redhat 8.0) using mysql 3.23 client software. When run on a platform with MySQL 5.0 (suse 10.1) software you're solution by raising the NotImplemented exception works. redhat 8.0 + mysql 3.23 client + python-mysql

Re: [sqlalchemy] joinedload option changes outcome of recursive query

2012-09-18 Thread Ladislav Lenart
Ok, thank you. I know about SELECT a, b FROM x ORDER BY c I just don't know how to write it because I (think I) need to define the literal column as one of the CTE columns. I have to increment it in each iteration. I will play with it for a while and see where it will lead me to. Thank you

[sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Ladislav Lenart
Hello. I have isolation issues with unit testing with SQLAlchemy. My DbTestCase looks like this (I use nose test framework): class DbTestCase(object): Db-aware test case superclass. __engine_name__ = 'postgres' __db_name__ = 'unit_tests' __echo__ = True @property def

Re: [sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Ladislav Lenart
Hello again. The problem is in sqlalchemy.orm.mapper. There are globals _mapper_registry and a boolean _new_mappers that triggers recompilation of the mappers. Is there a safe way to clear them in each test's case tearDown? Thank you in advance, Ladislav Lenart On 18.9.2012 16:07, Ladislav

Re: [sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Michael Bayer
the _mapper_registry is weak referencing, so doesn't have any impact on mappers hanging around or not. Ultimately, the mapper is associated with your mapped class. The clear_mappers() API call will de-associate mappers from classes and remove instrumentation that was affixed by the

Re: [sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Claudio Freire
On Tue, Sep 18, 2012 at 11:07 AM, Ladislav Lenart lenart...@volny.cz wrote: def create_base(): return declarative_base(cls=_Base) Move the declaration of _Base to within create_base, and I think that should fix your problem. (I've had a similar one, not with test cases, but with a replica

Re: [sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Ladislav Lenart
Hello. Adding call to clear_mappers() to tearDown fixed my problem. For the rest of the discussion I am not sure I completely follow. I use declarative exclusively but each test defines its own Base and its own set of ORM classes. However when one test has a bug in an ORM class definition, ALL

Re: [sqlalchemy] [Q] Lack of isolation in unit tests

2012-09-18 Thread Michael Bayer
On Sep 18, 2012, at 11:36 AM, Ladislav Lenart wrote: Hello. Adding call to clear_mappers() to tearDown fixed my problem. For the rest of the discussion I am not sure I completely follow. I use declarative exclusively but each test defines its own Base and its own set of ORM classes.

[sqlalchemy] Double quoted name column problem (Sqlite)

2012-09-18 Thread Massi
Hi everyone, I'm using sqlalchemy 0.7.8 with sqlite and I'm encountering a problem trying to retrieve data from a table having a column named input_1. If I run this simple code: from sqlalchemy import * db = create_engine('sqlite:///test.db') db.echo = False metadata = MetaData(db) t =

[sqlalchemy] Using unlisted dialect to connect with sqlanydb

2012-09-18 Thread lehmann
Hello, the Python DB-API 2.0 driver 'sqlanydb' for SQL Anywhere works fine and I'd like to use the SQLAlchemy connection pool within Pyramid. Unfortunately, SQLAlchemy doesn't let me use sqlanydb. Actually, I don't need any ORM stuff for the start, but if its required, the mssql dialect

Re: [sqlalchemy] Using unlisted dialect to connect with sqlanydb

2012-09-18 Thread Michael Bayer
On Sep 18, 2012, at 1:14 PM, lehm...@cnm.de wrote: Hello, the Python DB-API 2.0 driver 'sqlanydb' for SQL Anywhere works fine and I'd like to use the SQLAlchemy connection pool within Pyramid. Unfortunately, SQLAlchemy doesn't let me use sqlanydb. if you want pooling of a DBAPI and

[sqlalchemy] aborting insert/update from within before_insert/update events?

2012-09-18 Thread Gerald Thibault
I am working with 2 models, a Location model, and a Phone model. There is a one-to-many relationship between them. When a phone number is submitted, I need to format it using the phonenumbers modules, which requires a country code, which exists on the Location object. So the formatting can

Re: [sqlalchemy] aborting insert/update from within before_insert/update events?

2012-09-18 Thread Michael Bayer
On Sep 18, 2012, at 6:28 PM, Gerald Thibault wrote: I am working with 2 models, a Location model, and a Phone model. There is a one-to-many relationship between them. When a phone number is submitted, I need to format it using the phonenumbers modules, which requires a country code,

[sqlalchemy] Re: Double quoted name column problem (Sqlite)

2012-09-18 Thread Massi
After a little search, I found that the problem is due to line 684 of the file C:\Python27\Lib\site-packages\sqlalchemy\dialects\sqlite\base.py. The column names of the table are processed with this regular expression command: name = re.sub(r'^\|\$', '', name) which substitutes the first

Re: [sqlalchemy] aborting insert/update from within before_insert/update events?

2012-09-18 Thread Gerald Thibault
We're using a modified version of tastypie, with all the django-specific stuff modified to work with sqlalchemy. One of the things this offers is the ability to submit nested resources to API endpoints, and have it recursively build them by creating the parents, then appending the children to

Re: [sqlalchemy] aborting insert/update from within before_insert/update events?

2012-09-18 Thread Michael Bayer
On Sep 18, 2012, at 8:04 PM, Gerald Thibault wrote: We're using a modified version of tastypie, with all the django-specific stuff modified to work with sqlalchemy. One of the things this offers is the ability to submit nested resources to API endpoints, and have it recursively build them

Re: [sqlalchemy] Re: Double quoted name column problem (Sqlite)

2012-09-18 Thread Michael Bayer
I'm surprised that I can get you a really good chronology for why this is here, as it is some very old stuff. Here's the SQLAlchemy changeset which added that logic, including the test, which was failing at that time: http://hg.sqlalchemy.org/sqlalchemy/rev/cf5fbf20da45 The issue at that time