Re: [sqlalchemy] Automatically retrieving the row index

2011-04-07 Thread Mike Conley
Take a look at using ordering_list for the collection class on your relation. You add a position in season and SQLAlchemy will maintain the value. http://www.sqlalchemy.org/docs/orm/extensions/orderinglist.html -- Mike Conley -- You received this message because you are subscribed to the

[sqlalchemy] [None vs. NaN] Is there a Database independent way with SQLAlchemy to query filtered by “None”/“NaN”?

2011-04-07 Thread Philipp Rautenberg
The following code is DB specific: import sqlalchemy # ... ergebnis = session.query( my_object.attr1).filter(sa.and_( my_object.attr2 != 'NaN')).all() # PostgreSQL # my_object.attr2 != None)).all() # sQLite With PostgreSQL it is 'NaN', with SQLite None

[sqlalchemy] Sqlalchemy+sqlite3 autoload problem

2011-04-07 Thread Massi
Hi everyone, I'm writing a script using sqlalchemy 0.66 and sqlite3. I'm encountering a problem trying to create and load a table from two different engines. Here is an example script showing the problem: from sqlalchemy import * engine1 = create_engine(sqlite:///test.db, echo=False) metadata1 =

Re: [sqlalchemy] pyodbc + FreeTDS segfault?? on linux

2011-04-07 Thread Michael Bayer
On Apr 7, 2011, at 12:46 AM, Randy Syring wrote: I am running Ubuntu 10.04, python 2.6.5, SA 0.6.6, latest pyodbc release. I have tried FreeTDS that ships with the distro (0.82) as well as current CVS. I can make a connection and issue a basic SQL statement. However, when I try to run my

Re: [sqlalchemy] Sqlalchemy+sqlite3 autoload problem

2011-04-07 Thread Michael Bayer
On Apr 7, 2011, at 9:35 AM, Massi wrote: Hi everyone, I'm writing a script using sqlalchemy 0.66 and sqlite3. I'm encountering a problem trying to create and load a table from two different engines. Here is an example script showing the problem: from sqlalchemy import * engine1 =

Re: [sqlalchemy] [None vs. NaN] Is there a Database independent way with SQLAlchemy to query filtered by “None”/“NaN”?

2011-04-07 Thread Michael Bayer
On Apr 7, 2011, at 1:25 AM, Philipp Rautenberg wrote: The following code is DB specific: import sqlalchemy # ... ergebnis = session.query( my_object.attr1).filter(sa.and_( my_object.attr2 != 'NaN')).all() # PostgreSQL # my_object.attr2 !=

[sqlalchemy] ObjectDeletedError when query.delete() hits an expired item

2011-04-07 Thread Bobby Impollonia
Hi. With SQLA 0.6.6, the program below fails on the last line with ObjectDeletedError. Is this expected or a bug? from sqlalchemy import create_engine, MetaData, Column, Unicode from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base engine =

[sqlalchemy] Problem with SAWarning: Multiple rows returned with uselist=False

2011-04-07 Thread Aleksander Siewierski
Hi, in part of my model I have a TaskIntro item and RedirectRule item connected with relation one-to-one one-sided, mapper for TaskIntro looks like: mapper( TaskIntro, table, version_id_col = table.c.version , properties={ ...

Re: [sqlalchemy] ObjectDeletedError when query.delete() hits an expired item

2011-04-07 Thread Michael Bayer
it is a bug and ticket 2122 has the fix for this. However I'd like to target this at 0.7 since it rearranges things in update()/delete() significantly and I'd like to add test coverage for all the changes that have been made. The workaround for 0.6 is to pass False or fetch to the delete()

Re: [sqlalchemy] Problem with SAWarning: Multiple rows returned with uselist=False

2011-04-07 Thread Michael Bayer
On Apr 7, 2011, at 11:07 AM, Aleksander Siewierski wrote: Hi, in part of my model I have a TaskIntro item and RedirectRule item connected with relation one-to-one one-sided, mapper for TaskIntro looks like: mapper( TaskIntro, table, version_id_col =

[sqlalchemy] Re: when is object.id initialized

2011-04-07 Thread Lars
OK, thanks, this was part of the ActiveRecord kind of approach I was playing with, which after reading your article at zzzeek and the alternative described there I will probably shelve. On Apr 6, 9:59 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 6, 2011, at 6:38 AM, farcat wrote:

[sqlalchemy] Re: how to delete record (special case)

2011-04-07 Thread Lars
Hi Michael, I am trying to run the alternative you described in the article, but the following code is most likely from an old version of SA a don't know how to update (I am working with 6.6): mapper = class_mapper(cls) table = mapper.local_table

[sqlalchemy] multiple inheritance experiment

2011-04-07 Thread Lars
Hello, I am pretty determined to find a way to get (a simplified version of) multiple inheritance working with SA. The simplification lies in that no overriding of attributes will be possible (but I don't know whether that is significant). I was thinking of a schema as follows:

Re: [sqlalchemy] multiple inheritance experiment

2011-04-07 Thread Michael Bayer
On Apr 7, 2011, at 2:30 PM, Lars wrote: Hello, I am pretty determined to find a way to get (a simplified version of) multiple inheritance working with SA. The simplification lies in that no overriding of attributes will be possible (but I don't know whether that is significant). I was

[sqlalchemy] Re: pyodbc + FreeTDS segfault?? on linux

2011-04-07 Thread Randy Syring
Seems to be a unicode conversion problem, if you are interested in following, the pyodbc issue with very small test case is here: http://code.google.com/p/pyodbc/issues/detail?id=170 On Apr 7, 9:37 am, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 7, 2011, at 12:46 AM, Randy Syring

[sqlalchemy] Avoiding spaghetti inheritance

2011-04-07 Thread Luca Lesinigo
Hello there. I'm using SA-0.7 to develop an application that should help me manage my company's services. A central concept here is the order, it could be a service (like one year of web hosting) or a physical item (like a pc we sell). So far I generalized them in two classes: the Order and the

[sqlalchemy] DetachedInstanceError when calling __repr__

2011-04-07 Thread BenH
Hi, I have an objects that when I convert to a string using __repr__ throws a DetachedInstanceError. If I access any of their members or test the session (using 'user in Session') everything is fine but if I check 'self in Session' in __repr__ the result is False. I can reattach it to the Session

Re: [sqlalchemy] DetachedInstanceError when calling __repr__

2011-04-07 Thread Michael Bayer
On Apr 7, 2011, at 9:54 PM, BenH wrote: Hi, I have an objects that when I convert to a string using __repr__ throws a DetachedInstanceError. If I access any of their members or test the session (using 'user in Session') everything is fine but if I check 'self in Session' in __repr__ the