On Feb 26, 2009, at 12:40 AM, a.fowler wrote:
> > Hello, > > A couple of questions on the tutorial: > > 1) Why .all() in 3rd (and some others) "query" code box, but not > others? .all() is essentially equivalent to list(query). Some of the examples already iterate the query, such as for x in query: print x, others don't - but the tutorial wants you to see the results. Ideally none of the examples would use all() since you generally iterate to get results. > > > 2) Filter clause: Why '==' vs. '=' used in .filter() vs. .filter_by > () the argument signature of filter() is: filter(argument) whereas that of filter_by() is: filter_by(**kwargs) the "argument" is a clause expression. SQLAlchemy generates clause expressions when you call overridden Python operators like == (__eq__()) and similar. The SQL expression tutorial spends a little more time on this concept. > 3) Common Filter Operators: Why or_(), and_(), in_(), but like(). > (instead of like_() ) or/and/in are Python reserved words, it's convention per pep8 to rename functions/variables with a trailing underscore if they conflict. > 4) Common Filter Operators: Is '!= None' the correct way to get a "NOT > NULL"? (Not mentioned in tutorial) that will work yes > 5) Common Filter Operators: Using User.name.match raised an > "(OperationalError) unable to use function MATCH in the requested > context"... why? (using sqlite:memory is per tutorial) MATCH is not supported by every database, SQLite is apparently one of them. I'm a little surprised that operator found its way into the tutorial since I've never used it.... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---