[sqlalchemy] relationship trouble when using UsageRecipes/Views

2011-09-07 Thread werner
I am working on my localization stuff and run into a problem when I want to add an relationship to a class. I based my code on http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Views , but maybe I messed something up. The following works: r1 = session.query(db.Region_LV).get(175) print

Re: [sqlalchemy] subqueryload for a ColumnProperty?

2011-09-07 Thread Michael Bayer
For a deferred() itself, we don't have an option that does this.Though this is an unusual request. If you definitely want the deferreds to load, what's the issue having them render inline into the original query ?The advantage to subqueryload is primarily in that it loads multiple

Re: [sqlalchemy] relationship trouble when using UsageRecipes/Views

2011-09-07 Thread Michael Bayer
On Sep 7, 2011, at 4:40 AM, werner wrote: or: Region_LV.language = sao.relationship('Language', primaryjoin=Country_LV.fk_language_id==Language.id, foreign_keys=[Country_LV.__table__.c.fk_language_id]) I get: sqlalchemy.exc.ArgumentError: Column-based

Re: [sqlalchemy] relationship trouble when using UsageRecipes/Views

2011-09-07 Thread werner
Michael, On 09/07/2011 05:10 PM, Michael Bayer wrote: On Sep 7, 2011, at 4:40 AM, werner wrote: or: Region_LV.language = sao.relationship('Language', primaryjoin=Country_LV.fk_language_id==Language.id, foreign_keys=[Country_LV.__table__.c.fk_language_id])

Re: [sqlalchemy] relationship trouble when using UsageRecipes/Views

2011-09-07 Thread Michael Bayer
On Sep 7, 2011, at 11:53 AM, werner wrote: Michael, On 09/07/2011 05:10 PM, Michael Bayer wrote: On Sep 7, 2011, at 4:40 AM, werner wrote: or: Region_LV.language = sao.relationship('Language', primaryjoin=Country_LV.fk_language_id==Language.id,

[sqlalchemy] CircularDependencyError, why?

2011-09-07 Thread Erkan Özgür Yılmaz
The following gives CircularDependencyError where I think there isn't, but you know I don't know that much the internals of SQLAlchemy and maybe (and it is a strong possibility) I'm wrong. I've ripped of the classes causing the error (copy/paste will re-produce the error). from sqlalchemy import

Re: [sqlalchemy] CircularDependencyError, why?

2011-09-07 Thread Michael Bayer
On Sep 7, 2011, at 12:36 PM, Erkan Özgür Yılmaz wrote: The following gives CircularDependencyError where I think there isn't, but you know I don't know that much the internals of SQLAlchemy and maybe (and it is a strong possibility) I'm wrong. I've ripped of the classes causing the error

Re: [sqlalchemy] CircularDependencyError, why?

2011-09-07 Thread Erkan Özgür Yılmaz
Oh, that worked very well, thank you very much... E.Ozgur Yilmaz Lead Technical Director eoyilmaz.blogspot.com On Wed, Sep 7, 2011 at 8:04 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Sep 7, 2011, at 12:36 PM, Erkan Özgür Yılmaz wrote: The following gives CircularDependencyError

Re: [sqlalchemy] one-to-many with mixins in inherited classes

2011-09-07 Thread Erkan Özgür Yılmaz
I forgot to say thank you, I've solved it as you suggested and created a TaskableEntity for task related entities... E.Ozgur Yilmaz Lead Technical Director eoyilmaz.blogspot.com On Sun, Sep 4, 2011 at 11:35 PM, Michael Bayer mike...@zzzcomputing.comwrote: TaskMixin.tasks places a

Re: [sqlalchemy] relationship trouble when using UsageRecipes/Views

2011-09-07 Thread werner
On 09/07/2011 05:58 PM, Michael Bayer wrote: On Sep 7, 2011, at 11:53 AM, werner wrote: Michael, On 09/07/2011 05:10 PM, Michael Bayer wrote: On Sep 7, 2011, at 4:40 AM, werner wrote: or: Region_LV.language = sao.relationship('Language',

[sqlalchemy] order_by on model property

2011-09-07 Thread Tim Black
What is the right way to use .order_by() to order by the values returned by a model object property? My model object is like this: class Project(DeclarativeBase): __tablename__ = 'project' id = Column(Integer, primary_key=True) ... @property def remainderDue(self):

Re: [sqlalchemy] order_by on model property

2011-09-07 Thread Michael Bayer
You'd use a hybrid for this case, and due to the usage of float() you'd probably want to produce a separate @expression that doesn't rely on a Python function. Docs and examples for hybrid are at http://www.sqlalchemy.org/docs/orm/extensions/hybrid.html Separate @expression:

Re: [sqlalchemy] subqueryload for a ColumnProperty?

2011-09-07 Thread Sumeet Agarwal
Still getting the hang of SQLAlchemy terminology. I didn't mean a simple deferred() column, but a deferred column_property() which defines a scalar select(). Like in the example here http://www.sqlalchemy.org/docs/orm/mapper_config.html#sql-expressions-as-mapped-attributes . My goal is to,

Re: [sqlalchemy] subqueryload for a ColumnProperty?

2011-09-07 Thread Michael Bayer
On Sep 7, 2011, at 5:09 PM, Sumeet Agarwal wrote: Still getting the hang of SQLAlchemy terminology. I didn't mean a simple deferred() column, but a deferred column_property() which defines a scalar select(). Like in the example here

Re: [sqlalchemy] Question on session.expunge.all()

2011-09-07 Thread Vlad K.
Great, thanks! .oO V Oo. On 09/06/2011 04:48 PM, Michael Bayer wrote: On Sep 6, 2011, at 10:40 AM, Vlad K. wrote: I have a products database which is daily syncronized with an external source via a csv file. There are several thousand rows in question. The synchronization does two

[sqlalchemy] PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-07 Thread Victor Olex
Using SQLAlchemy 0.7.2 with pyodbc 2.1.9, FreeTDS 0.91, unixODBC 2.3.0 and SQL Server 2008 I find that the supports_unicode_bind may be incorrectly set to False in the PyODBCConnector.initialize. As a result a unicode parameter gets encoded as str and to make matters worse the value gets silently

Re: [sqlalchemy] PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-07 Thread Michael Bayer
I can't actually make that string work at all with FreeTDS, but I am on 0.82. If I turn on Python unicodes with FreeTDS 0.82, which until recently was the FreeTDS release for years, everything breaks immediately - the CREATE TABLE statements won't even work, as you can see below just the

Re: [sqlalchemy] PyODBCConnector, possible wrong assumption re Unicode in bind parameters

2011-09-07 Thread Michael Bayer
The ticket for SQLAlchemy is: http://www.sqlalchemy.org/trac/ticket/2273 For Pyodbc I've opened: http://code.google.com/p/pyodbc/issues/detail?id=209 http://code.google.com/p/pyodbc/issues/detail?id=210 as you can see, issue 210 is quite serious.Would be curious what results you get for