[sqlalchemy] with_polymorphic mapper option for future classes

2011-07-20 Thread Torsten Landschoff
Hi *, is there a way to use the with_polymorphic mapper option for classes yet to be defined? My problem is that I have a base class for a number of different database objects. There are few specific leafs classes of which many instances are loaded at once. Currently, I pass

[sqlalchemy] how to get last record from a resultset

2011-07-20 Thread Krishnakant Mane
Hello all, Subject line says it all. Basically what I want to do is to get last record from a result set. I am dealing with a situation where given a date I need to know the last record pertaining to transaction on a given account. yes, it is an accounting/ book keeping software. So I

Re: [sqlalchemy] with_polymorphic mapper option for future classes

2011-07-20 Thread Michael Bayer
perhaps we'd want to establish mapper.with_polymorphic as a setter that will perform the requisite validations on it whenever it is set.I think you can set it right now on the mapper at any point, it doesn't seem to be consulted in any configurational way. The only validations that occur

Re: [sqlalchemy] Occasional ProgrammingError in threaded environment

2011-07-20 Thread Michael Bayer
On Jul 20, 2011, at 1:50 AM, Arthur Kopatsy wrote: Hi, My web application has a controller that spawns multiple threads using a thread pool. Each of them has its own session (I store it in thread local). Occasionally (1 out of 100 or more) I get really strange errors that really look

Re: [sqlalchemy] how to get last record from a resultset

2011-07-20 Thread Timuçin Kızılay
I think, reversing the sort and getting the first record will do. 20-07-2011 16:32, Krishnakant Mane yazmış: Hello all, Subject line says it all. Basically what I want to do is to get last record from a result set. I am dealing with a situation where given a date I need to know the last

Re: [sqlalchemy] how to get last record from a resultset

2011-07-20 Thread Krishnakant Mane
Well, there won't be a consistent result using sort because there might be 10 rows with same voucher code and same account code. That's exactly the challenge so I don't know how sort will help. If we can invert the entire resultset having the last record become first, then its worth while.

RE: [sqlalchemy] how to get last record from a resultset

2011-07-20 Thread King Simon-NFHD78
If you don't have something consistent to sort by, then I'm not sure that the last record is meaningful, is it? If you have 10 rows with the same voucher code and account code (and there is nothing else to uniquely identify them, such as a more precise timestamp, or an auto-incrementing ID),

[sqlalchemy] Re: Occasional ProgrammingError in threaded environment

2011-07-20 Thread Arthur Kopatsy
Hi Michael, I indeed had a object hanging around and being shared across threads... Thanks for the hint, you saved my week! Arthur On Jul 20, 6:46 am, Michael Bayer mike...@zzzcomputing.com wrote: On Jul 20, 2011, at 1:50 AM, Arthur Kopatsy wrote: Hi, My web application has a controller

[sqlalchemy] order_by with property of related table

2011-07-20 Thread gwozdziu
Hi! I have two tables: A and B defined something like that: A: Column('id', Integer, primary_key=True), Column('name', Unicode(256)), Column('b_id', Integer, ForeignKey('b.id')) B: Column('id', Integer, primary_key=True), Column('name', Unicode(256)),

[sqlalchemy] py32 TypeError: unorderable types: str() int()

2011-07-20 Thread ddarko
declarative_base tmp = session.query(Opt).all() session.add(Opt(key='a', value='b')) session.commit() File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.1- py3.2.egg/sqlalchemy/orm/session.py, line 617, in commit self.transaction.commit() File

Re: [sqlalchemy] py32 TypeError: unorderable types: str() int()

2011-07-20 Thread Michael Bayer
Can I ask that you put a little more effort into providing context / mappings / specifics for this stack trace (see guidelines at http://www.sqlalchemy.org/support.html#mailinglist ) ? Clearly If I make a sample Opt() class with two fields and commit it, no such error occurs. There is some

[sqlalchemy] Re: py32 TypeError: unorderable types: str() int()

2011-07-20 Thread ddarko
That is very strange. I am from a few hours struggling with this ... stripped application on the first ... There is nothing else. Ordinary simple table. On it a select and an insert (with ORM, of course). Rest a while and try to prepare a complete test case. Unless I find a solution on the way :]