[sqlalchemy] Re: how to walk through a query result

2009-01-12 Thread Werner F. Bruhin
Michael, Thanks for the quick reply. Michael Bayer wrote: On Jan 11, 2009, at 4:51 PM, Werner F. Bruhin wrote: I can not find the answer looking through the 0.5 doc for my problem. query = session.query(db.SomeClass).filter(something).order_by(anorder) # get the first row row =

[sqlalchemy] How to query with aggregate function?

2009-01-12 Thread Chen Houwu
I am not very familiar with SA, now I have a problem to query with aggregate function. Here is the class -- class Directory(DeclarativeBase): An ultra-simple group definition. __tablename__ = 'docman_directory' dir_id = Column(Integer, autoincrement=True,

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-12 Thread MikeCo
Must have been a bug in the default constructor prior to 0.5.0 final. I got the same error rerunning with earlier version. Strange, I don't remember now how I had this running before. Maybe with my own constructor, but not worth igging to find out, it works with final release. On Jan 11, 1:43 

[sqlalchemy] Re: Self-Referential Mapping with Base?

2009-01-12 Thread Michael Bayer
yes, it was a bug that declarative wasn't translating the backref() arguments from strings. On Jan 12, 2009, at 10:22 AM, MikeCo wrote: Must have been a bug in the default constructor prior to 0.5.0 final. I got the same error rerunning with earlier version. Strange, I don't remember now

[sqlalchemy] ORM base class for 0.5?

2009-01-12 Thread Christoph Haas
Dear list, I used to use a certain ORM base class with SQLA 0.4 for a while. It defined __init__, __repr__ and update so that I could preset mapped objects with values like leo = User(name='leo', age=23) or just print leo and especially

[sqlalchemy] Re: ORM base class for 0.5?

2009-01-12 Thread az
def __init__( me, **ka): for k,v in ka.iteritems(): setattr( me,k,v) def update( me, ka): for k,v in ka.iteritems(): setattr( me,k,v) generic repr/str is more tricky... one way is like: for p in object_mapper(self).iterate_properties: print getattr( self, p.key) or was

[sqlalchemy] Re: 0.5: Could not determine join condition - Bug?

2009-01-12 Thread Michael Bayer
no bug in contains_column: from sqlalchemy import * m = MetaData() table = Table('t2', m, Column('asl_id', Integer, ForeignKey('public.asl_list_view.asl_id')), schema='public' ) asl_list_view = Table('asl_list_view', m, Column('asl_id', Integer),

[sqlalchemy] Re: 0.5: Could not determine join condition - Bug?

2009-01-12 Thread _tyr_
thx for your reply. Sometimes i got obsolete objects: (Pdb) id( llm_mapper.local_table.foreign_keys[0].column ) 447124816 -obsolete column object, but semantically ok (Pdb) id( mapper.local_table.c['asl_id'] ) 448983376 -valid column object (Pdb) id(

[sqlalchemy] How best to handle metadata in WSGI framework

2009-01-12 Thread PacSci
I've decided that for a WSGI framework I'm working on (based on Werkzeug, if that helps) that SQLAlchemy will be the official ORM - as in, the framework will handle the database side of the equation and the user just provides the models. However, I am trying to figure out how to make sure that

[sqlalchemy] Re: 0.5: Could not determine join condition - Bug?

2009-01-12 Thread Michael Bayer
On Jan 12, 2009, at 8:16 PM, _t...@arcor.de wrote: thx for your reply. Sometimes i got obsolete objects: (Pdb) id( llm_mapper.local_table.foreign_keys[0].column ) 447124816 -obsolete column object, but semantically ok (Pdb) id( mapper.local_table.c['asl_id'] ) 448983376 -valid

[sqlalchemy] Re: How best to handle metadata in WSGI framework

2009-01-12 Thread Michael Bayer
On Jan 12, 2009, at 6:09 PM, PacSci wrote: I've decided that for a WSGI framework I'm working on (based on Werkzeug, if that helps) that SQLAlchemy will be the official ORM - as in, the framework will handle the database side of the equation and the user just provides the models. However,

[sqlalchemy] Re: How best to handle metadata in WSGI framework

2009-01-12 Thread PacSci
Thank you for the insight. However, the thing is, while this Official Metadata is handled on an app-level basis, I'm looking for something that will span multiple apps. (I'm thinking of projects and apps as Django does, with projects being individual deployments and apps being distinct packages

[sqlalchemy] Re: How best to handle metadata in WSGI framework

2009-01-12 Thread Michael Bayer
On Jan 12, 2009, at 9:15 PM, PacSci wrote: Thank you for the insight. However, the thing is, while this Official Metadata is handled on an app-level basis, I'm looking for something that will span multiple apps. (I'm thinking of projects and apps as Django does, with projects being

[sqlalchemy] 0.5 + pyodbc + Custom Types

2009-01-12 Thread fw
Hi guys, I have an application running under 0.4.7p1 It access a MSSQL server using pymssql. Now I am trying to see if I can port it to 05 and use pyodbc (2.1.4). I am experiencing a strange problem. I have defined some custom column types (see below) to deal with some legacy database.

[sqlalchemy] Re: 0.5 + pyodbc + Custom Types

2009-01-12 Thread Michael Bayer
you're using methods which have been removed (which were also deprecated throughout 0.4). Check out the third bulletpoint here: http://www.sqlalchemy.org/trac/wiki/05Migration#SchemaTypes On Jan 12, 2009, at 10:29 PM, fw wrote: class IntString(sa.types.TypeDecorator): A string

[sqlalchemy] Re: 0.5 + pyodbc + Custom Types

2009-01-12 Thread fw
Hi Michael, Thanks for the reply. And sorry for the dumb question Sometimes I can't see what is just in front of my nose. Regards, François On Jan 13, 10:46 am, Michael Bayer mike...@zzzcomputing.com wrote: you're using methods which have been removed (which were also   deprecated

[sqlalchemy] 0.5.0 polymorphic merge problem or bug

2009-01-12 Thread Duder
I have a problem merging a polymorphic persistent object. Please read my description of the problem below. Sorry if it's a little complex. I've got a polymorphic mapper defined as so: sqlalchemy.orm.mapper(Generic, generics_table, polymorphic_on=generics_table.c.type,

[sqlalchemy] Re: 0.5.0 polymorphic merge problem or bug

2009-01-12 Thread Michael Bayer
On Jan 12, 2009, at 11:37 PM, Duder wrote: missing from the object, so it is generating bad SQL. Is this a bug, or do I need to change something to be compatible with 0.5.0? its impossible to say without a full reproducing test case. I've tried many versions of the test below and none

[sqlalchemy] Re: 0.5.0 polymorphic merge problem or bug

2009-01-12 Thread Michael Bayer
I have detected the sole codepath which does in fact produce the output you've seen which is also erroneous. That issue is fixed in r5661. However, the reproduction of the bug is doesn't appear possible with the scenario you describe, which suggests that your serialization/merge scheme