[sqlalchemy] Bidirectional relationships with association proxies

2011-08-31 Thread Benjamin Sims
Hi, I'm still having troubles correctly figuring my various many-to-many relations. Originally, this was a 'standard' many-to-many; that is, a secondary table was specified. However, I now need to add further information to the relation and am converting into an AssociationObject. My problem is

[sqlalchemy] Case-insensitive select

2011-08-31 Thread RVince
I'm using Postgres and the end-users are complaining that the search features provided by the web app are case-sensitive (via Postgres). Is there a way to do a case-insensitive version of select statements? Not all statements are of the form = or like but often of the form ...where lastname =

[sqlalchemy] self referencing many-to-many association object

2011-08-31 Thread bika
Hi, I could someone help me in putting together a self-referencing association object? The docs write about self-referencing many2many and association objects separately, but I simply can't figure out how merge the two techniques (for example one uses declarative, the other doesn't) This is

Re: [sqlalchemy] Re: Versioning and multi-level inheritance

2011-08-31 Thread Michael Bayer
version is only on your Container table since it will always have a row corresponding to each Box row, so box.version is not necessary. You can change this by changing: if not super_history_mapper: cls.version = Column('version', Integer, default=1, nullable=False) to:

[sqlalchemy] Apparent inconsistency between defining Index() and UniqueConstraint()

2011-08-31 Thread Kent
Defining an Index() or UniqueConstraint() within a Table(...) adds the schema item to the table. Defining an Index() by passing one or more columns also adds the Index to the Table. However, defining a unique constraint by itself and passing columns does *not* add the constraint to the

[sqlalchemy] Re: Apparent inconsistency between defining Index() and UniqueConstraint()

2011-08-31 Thread Kent
Nevermind... my bad. I finally figured out you don't pass a name as the first parameter to a UniqueConstraint. Sorry. On Aug 31, 1:57 pm, Kent jkentbo...@gmail.com wrote: Defining an Index() or UniqueConstraint() within a Table(...) adds the schema item to the table.  Defining an Index()

Re: [sqlalchemy] Re: Versioning and multi-level inheritance

2011-08-31 Thread JPLaverdure
Hi Michael, Thank you for your reply. Unfortunately, the mistake was all mine... At some point (and for an obscure reason...), I had stopped using the VersionedListener so changes were no longer registering in the DB :-/ So sorry ! JP -- You received this message because you are subscribed

Re: [sqlalchemy] Re: Versioning and multi-level inheritance

2011-08-31 Thread Jean-Philippe Laverdure
Hi Michael, Thank you for your reply. Unfortunately, the mistake was all mine... At some point (and for an obscure reason...), I had stopped using the VersionedListener so changes were no longer registering in the DB :-/ So sorry ! JP On Wed, Aug 31, 2011 at 12:23 PM, Michael Bayer

[sqlalchemy] Re: Calculating percentage using subquery

2011-08-31 Thread nospam
I get an error saying the countall doesn't appear in the groupby, or its not an aggregating function. sqlalchemy.exc.ProgrammingError: (ProgrammingError) column anon_2.countall must appear in the GROUP BY clause or be used in an aggregate function session = SqlMapping().createSession()

[sqlalchemy] Re: Calculating percentage using subquery

2011-08-31 Thread nospam
Nevermind. This seems to work: subq = session.query(func.count('*').label('countall')).select_from(ReportableCondition).subquery() qry = session.query(ReportableCondition.disease, func.count(1).label('number'), (cast(100*func.count(1), Float) /

Re: [sqlalchemy] Bidirectional relationships with association proxies

2011-08-31 Thread Michael Bayer
dependency rule tried to blank out primary key means: 1. A references B, B has a foreign key to A. 2. A is deleted. 3. each B associated with A must therefore have the foreign key of A set to NULL (this is the default behavior if 'delete' cascade isn't configured). 4. the foreign key on B is

Re: [sqlalchemy] self referencing many-to-many association object

2011-08-31 Thread Michael Bayer
ForeignKey accepts the name of the table in its string argument, hence the error could not find *table* 'Character', so that would be ForeignKey('characters.id'). Additionally, since there is more than one way to join characters to sympathylists, you'll need primaryjoin on each relationship.

Re: [sqlalchemy] Case-insensitive select

2011-08-31 Thread Michael Bayer
Usually like this: from sqlalchemy import func query(Widget).filter(func.lower(Widget.name) == func.lower(Some name)) if you're using LIKE, you can use ILIKE instead which is built in: Widget.name.ilike(Some Expression) On Aug 31, 2011, at 8:27 AM, RVince wrote: I'm using Postgres and the