Hi
After Idan's talk regarding django's new features, here are a few short
words regarding sqlobject & sqlalchemy.
For the last year or so I've been using sqlobject. I've also been using
sqlalchemy from time to time.
The most notable difference I saw when I read introductions to django was
how to do queries, which now it seems django improved, even though I think I
still prefer the sqlobject and sqlalchemy way.

sqlobject:
r = User.select(User.q.display_name.startswith('a') &
LIKE(User.q.email_address, '%google%'))
r = User.select(User.q.name == User.q.display_name)
You can also do this with multiple tables (just use another table's fields),
although currently I do the joins explicitly and not implicitly (this just
means specifying the join condition yourself). There's probably a way to do
them automatically, you can read about it in sqlobject's docs.

sqlalchemy:
To be honest, last time I used it, I had to use mssql, and I ended up
specifying the schema directly in mssql. Here, sqlalchemy's sqlsoup came to
the rescue, with something like (copying from their examples):

>>> from sqlalchemy.ext import sqlsoup
>>> db = sqlsoup.SqlSoup('sqlite:///:memory:')
....
>>> from sqlalchemy import or_, and_, desc
>>> where = or_(db.users.name=='Bhargan Basepair', db.users.email=='
[email protected]')
>>> db.users.filter(where).order_by(desc(db.users.name)).all()

Note that here we didn't even use a special field. If you use 'regular'
sqlalchemy, and not sqlsoup, you'll be specifying the fields with c,
something like:

my_session.query(User.c.name == User.c.display_name).all()

Afaict, sqlalchemy is a bit stronger, and more widely used than sqlobject.
On another subject, I must admit that django's annotate looks very nice, and
I haven't used these two libraries enough to know if such a feature exists
in them.

Cheers,
Imri


-- 
Imri Goldberg
--------------------------------------
www.algorithm.co.il/blogs/
--------------------------------------
-- insert signature here ----

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"PyWeb-IL" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyweb-il?hl=en
-~----------~----~----~----~------~----~------~--~---

_______________________________________________
Python-il mailing list
[email protected]
http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il

לענות