[sqlalchemy] Re: How to filter by the result of a subquery?

2009-07-16 Thread Ants Aasma
On Jul 16, 2:55 am, The Devil's Programmer thedevilsprogram...@gmail.com wrote: I believe I am supposed to wrap the whole query inside another query and put the where clause on the outer query, would this be correct? I have tried messing around with this a little but haven't managed to get it

[sqlalchemy] How to check for references before deleting?

2009-07-16 Thread Hermann Himmelbauer
Hi, I use in my database tables, that reference other tables, e.g. table A - table B. In my deletion routine, I want to prohibit people to delete rows from A, which have references to B. How would I do that? My first approach was to rely on the databases referential integrity and catch

[sqlalchemy] Re: How to check for references before deleting?

2009-07-16 Thread Michael Bayer
Hermann Himmelbauer wrote: Hi, I use in my database tables, that reference other tables, e.g. table A - table B. In my deletion routine, I want to prohibit people to delete rows from A, which have references to B. How would I do that? My first approach was to rely on the databases

[sqlalchemy] Postgres Indexes: specifying 'pattern_ops' to ensure proper indexing of LIKE% queries

2009-07-16 Thread johnnyp
Background -- I found that performing a select cols from mytable where X like 'foo %' was dog slow on my postgresql database. Analysing the query plan showed that, although X was indexed, the query was always performing a table scan. The database uses UTF-8 encoding, and after a

[sqlalchemy] Re: Postgres Indexes: specifying 'pattern_ops' to ensure proper indexing of LIKE% queries

2009-07-16 Thread Michael Bayer
johnnyp wrote: Background -- I found that performing a select cols from mytable where X like 'foo %' was dog slow on my postgresql database. Analysing the query plan showed that, although X was indexed, the query was always performing a table scan. The database uses UTF-8

[sqlalchemy] Queries in historical db's, where the join depends on having an overlapping timestamp (or other filter condition)

2009-07-16 Thread Gregg Lind
''' Based on the thread titled filter relation based on column value at http://groups.google.com/group/sqlalchemy/browse_thread/thread/0db7423d986ba543 and some others, I'm curious about how to better get my SqlA code working with historical (better term?) databases, where the relational state

[sqlalchemy] Re: Queries in historical db's, where the join depends on having an overlapping timestamp (or other filter condition)

2009-07-16 Thread Gregg Lind
That's a totally fair answer! Mostly, I wish some sense of relational change over time was built into SQL, the way it is in BigTable style systems. Maybe you could shed a little light on how to use the overlap operator? I'm having trouble getting the multiple fields into the clause statement.

[sqlalchemy] Re: Queries in historical db's, where the join depends on having an overlapping timestamp (or other filter condition)

2009-07-16 Thread jess
I believe that I asked Michael a similar question, in a different way, a few days ago. The answer was to use contains_eager. I used something like the following and it worked great to query what the membership of a group was at a specific time. The two tables remain simple, related by a

[sqlalchemy] Joined subquery, SQL syntax error

2009-07-16 Thread Julien Demoor
Hello, I have a query that fails when executed: the engine is passed the string representation of a sqlalchemy.sql.expression._BinaryExpression object as a parameter, resulting in a syntax error. This expression is part of a subquery which is joined to a table. There is a simplified exemple

[sqlalchemy] Re: Queries in historical db's, where the join depends on having an overlapping timestamp (or other filter condition)

2009-07-16 Thread Gregg Lind
Jess, Thanks for posting the actual class :) Just reading the description use contains_eager didn't tell me enough about how to make it happen. Cheers, Gregg On Thu, Jul 16, 2009 at 12:54 PM, jessjesslp...@gmail.com wrote: I believe that I asked Michael a similar question, in a different