[sqlalchemy] Re: Automatically filtering all queries

2009-05-27 Thread Denis S. Otkidach
On 26 май, 20:50, Michael Bayer mike...@zzzcomputing.com wrote: However, its quite easy to achieve.  Just use this. class LimitingQuery(Query):     def get(self, ident):         return Query.get(self.populate_existing(), ident)     def __iter__(self):         return

[sqlalchemy] Re: Changes in exc.py causing problems.

2009-05-27 Thread Bob Farrell
Hooray. \o/ I'll leave the code commented until I pull the next release. Cheers, On May 26, 6:03 pm, Michael Bayer mike...@zzzcomputing.com wrote: this is all fixed in the current trunk.  release probably today as the issue you have below is more severe than the one I had noticed. Bob

[sqlalchemy] Re: Questions on SQLA Queries

2009-05-27 Thread Timothy N. Tsvetkov
Q1. Good question %) I didn't find anything about it in docs (but i didn't search a lot), so i use map function to convert it to a list you want. And I think it is the right solution. Because if you query for more then one column (session.query(User.is, User.name).all()) a list of tuples is what

[sqlalchemy] Re: Questions on SQLA Queries

2009-05-27 Thread Harish Vishwanath
Thanks! Could you elaborate on how you use the map function? I couldn't find it myself in the docs. Regards, Harish On Wed, May 27, 2009 at 3:07 PM, Timothy N. Tsvetkov timothy.tsvet...@gmail.com wrote: Q1. Good question %) I didn't find anything about it in docs (but i didn't search a

[sqlalchemy] Re: Questions on SQLA Queries

2009-05-27 Thread Gregg Lind
I believe by map function, Timothy may be implying that you should use any of the python idioms for converting iterables of tuples to a straight tuple. The one I like best from itertools import chain q = session.query(User.name) #(User is a class) names = itertools.chain(*q.all() ) But you

[sqlalchemy] Re: Questions on SQLA Queries

2009-05-27 Thread Mike Conley
Q1. How about simple list comprehension? names = [row[0] for row in q.all()] Q2. This is an interesting question. The delete() method of query didn't give the result you are looking for: session.query(Movie).filter(year50).limit(30).delete() generates SQL delete from movie where year 50 so the

[sqlalchemy] Re: Questions on SQLA Queries

2009-05-27 Thread Mike Conley
And here is the tested version of the code I published earlier while True: ids = [row[0] for row in session.query(Movie.id).filter(Movie.year50).limit(30)] if len(ids) == 0: break session.query(Movie).filter(Movie.id.in_(ids)).delete(synchronize_session=False) session.flush()

[sqlalchemy] Performance, cd

2009-05-27 Thread Marcin Krol
Hello everyone, I nailed the problem with performance, it wasn't the 'big query' not loading collections, but this one: rsvs = session.query(Reservation).filter(Reservation.project_id.in_(projids)).filter(Reservation.status == 'pending').filter(Reservation.end_date todaydt).all() The

[sqlalchemy] Re: 0.5.4p2 Tests failed

2009-05-27 Thread Michael Bayer
the changes between 0.5.4p1 and 0.5.4p2 are extremely minimal and I've pasted them at http://paste.pocoo.org/show/119367/ .Additionally here they are passing for py2.4 and py2.5 at http://groovie.org:8012/ which is an intel linux platform. I run the tests with 2.6 here on an intel

[sqlalchemy] Re: Automatically filtering all queries

2009-05-27 Thread Michael Bayer
On May 27, 2009, at 4:25 AM, Denis S. Otkidach wrote: On 26 май, 20:50, Michael Bayer mike...@zzzcomputing.com wrote: However, its quite easy to achieve. Just use this. class LimitingQuery(Query): def get(self, ident): return Query.get(self.populate_existing(), ident)

[sqlalchemy] Re: Performance, cd

2009-05-27 Thread Michael Bayer
the Query.all() call only generates a single SQL statement at all times. Its only when you access attributes on individual rows that a second statement would occur. If the multiple queries truly occur within the scope of the all() call, I'd check to see if you have a @reconstructor or

[sqlalchemy] Re: Performance, cd

2009-05-27 Thread Marcin Krol
Hello Mike, Nailed it! Thanks a million, Mike! Michael Bayer wrote: the Query.all() call only generates a single SQL statement at all times. Its only when you access attributes on individual rows that a second statement would occur. If the multiple queries truly occur within the

[sqlalchemy] Re: 0.5.4p2 Tests failed

2009-05-27 Thread Melton Low
Hi Michael, I re-build my systems last night - zapped Python, Mercurial, Sqlite, pysqlite, psycopg, and SQLAlchemy. You 0.5.4p1 test suite ran perfectly as long as I only have the version of pysqlite included with Python. As I am going out of town, I decided to leave 0.5.4p2 alone for the time

[sqlalchemy] Re: 0.5.4p2 Tests failed

2009-05-27 Thread Michael Bayer
with the latest pysqlite (2.5.5) I also get a huge (192) amount of failures with many versions of SQLalchemy, including p1 and p2. I had noticed that pysqlite's development seemed to be going further with changes that make the library harder to develop against, but particularly

[sqlalchemy] Re: 0.5.4p2 Tests failed

2009-05-27 Thread Melton Low
The first time I installed pysqlite 2.5.5, my Mac 10.4 build fine but not on the 10.5. The solution from the pysqlite people was to build_static on 10.5. It seem to work the first time around. Unfortunately I was not able to get a clean install last night on either systems. So for the time

[sqlalchemy] Re: 0.5.4p2 Tests failed

2009-05-27 Thread Michael Bayer
DOH, oh right, I made the same mistake and just built pysqlite against an arbitrary SQLite version. WHEW my day just got shorter again :) . On May 27, 2009, at 11:21 AM, Melton Low wrote: The first time I installed pysqlite 2.5.5, my Mac 10.4 build fine but not on the 10.5. The solution

[sqlalchemy] postgres and/or generic enum support in sqlalchemy

2009-05-27 Thread Damian
Hi, http://www.sqlalchemy.org/trac/ticket/1109 Is this still being worked on? In particular it would be interesting to get this running for postgres for us. If not, I would like to have a go at it in the near future, or am happy to help test if someone else is working on this. Cheers, Damian

[sqlalchemy] Re: postgres and/or generic enum support in sqlalchemy

2009-05-27 Thread Michael Bayer
from my perspective my comments on the ticket still stand - the MySQL specificness has to be removed and the interface regarding encoding and such should be simplified.The MySQL import and __supported business should be removed as well - I know the Interval type is doing the same

[sqlalchemy] onclause in join in 5.3?

2009-05-27 Thread Marcin Krol
Hello everyone, Is there such a thing? I have to specify onclause since Host - Reservation is many-to-many, and if I don't specify onclause, I get exception Can't find any foreign key relationships between 'reservation' and 'hosts'. Docs: The onclause may be a string name of a relation(),

[sqlalchemy] Re: postgres and/or generic enum support in sqlalchemy

2009-05-27 Thread Dimmich Damian
Agreed - it makes more sense to have a generic enum type which may fall back to software should the db not actually support it. Having said that, in terms of using (selecting/updating) an enum field the syntax should be quite similar across implementations. While I'm not familiar with databases

[sqlalchemy] Re: onclause in join in 5.3?

2009-05-27 Thread Michael Bayer
query.join() takes an onclause as in the following: query.join((target, onclause), (target2, onclause2), ...) the onclause can be an expression or a named relation. see the examples in http://www.sqlalchemy.org/docs/05/ormtutorial.html#querying-with-joins . On May 27, 2009, at 11:54 AM,

[sqlalchemy] Re: 0.5.4p2 Tests failed

2009-05-27 Thread Michael Bayer
I did a static build of pysqlite 2.5.5 against sqlite 3.6.14. All tests pass except the single memory leak test. I'll see if i can isolate this for them. On May 27, 2009, at 11:21 AM, Melton Low wrote: The first time I installed pysqlite 2.5.5, my Mac 10.4 build fine but not on the

[sqlalchemy] Re: onclause in join in 5.3?

2009-05-27 Thread Michael Bayer
query.join() takes an onclause as in the following: query.join((target, onclause), (target2, onclause2), ...) the onclause can be an expression or a named relation. see the examples in http://www.sqlalchemy.org/docs/05/ormtutorial.html#querying-with-joins . On May 27, 2009, at 11:54 AM,

[sqlalchemy] Re: Automatically filtering all queries

2009-05-27 Thread Denis S. Otkidach
On 27 май, 18:22, Michael Bayer mike...@zzzcomputing.com wrote: On May 27, 2009, at 4:25 AM, Denis S. Otkidach wrote: class LimitingQuery(Query):     def get(self, ident):         return Query.get(self.populate_existing(), ident)     def __iter__(self):         return

[sqlalchemy] Re: postgres and/or generic enum support in sqlalchemy

2009-05-27 Thread Michael Bayer
On May 27, 2009, at 12:09 PM, Dimmich Damian wrote: Would it, based on the above assumption, not be possible to have a generic enum type that figures out what to do based on what type of database we are connected to without needing to specify MSEnum or the currently ficticious PGEnum?

[sqlalchemy] Accessing classes a table away in a mapper - why does this work?

2009-05-27 Thread Nathan Harmston
Hi, I have been struggling with trying to create relations which reference objects a couple of tables away. e.g Sentence has many entities Entity has many NormalisedVersion NormalisedVersion has one Gene kind of thing and was trying to link from Sentence to genes directly. secondary =

[sqlalchemy] Re: Automatically filtering all queries

2009-05-27 Thread Michael Bayer
On May 27, 2009, at 12:20 PM, Denis S. Otkidach wrote: Probably I have to hack something to insure proper subqueries construction. uh yeah if subqueries are happening, that makes things more complicated too. But the other DB tools you're comparing us against probably have a lot less

[sqlalchemy] Re: Accessing classes a table away in a mapper - why does this work?

2009-05-27 Thread Michael Bayer
On May 27, 2009, at 12:23 PM, Nathan Harmston wrote: Hi, I have been struggling with trying to create relations which reference objects a couple of tables away. e.g Sentence has many entities Entity has many NormalisedVersion NormalisedVersion has one Gene kind of thing and was

[sqlalchemy] Re: postgres and/or generic enum support in sqlalchemy

2009-05-27 Thread Dimmich Damian
Great :). So, what needs doing to get Enum support? The ticket, which is part of the 0.5.5 roadmap mentions adding tests, would having tests be sufficient for getting it into 0.5.5? Is it still worth writing a posgres/enum PGEnum type for 0.5.x and integrating it with the patch that is in the

[sqlalchemy] Re: postgres and/or generic enum support in sqlalchemy

2009-05-27 Thread Michael Bayer
On May 27, 2009, at 12:39 PM, Dimmich Damian wrote: Great :). So, what needs doing to get Enum support? The ticket, which is part of the 0.5.5 roadmap mentions adding tests, would having tests be sufficient for getting it into 0.5.5? tests plus the cleanup discussed. Is it still