Storm vs. SQLAlchemy
Gustavo Niemeyer
gustavo at niemeyer.net
Wed Jul 11 06:35:10 BST 2007
Hello Lucas,
> One of the things that makes an ORM like SQLObject handy is the fact
> that it can generate the schema in a database agnostic manner. Since
> Storm doesn't handle schema management, could I conclude that vendor
> specific ddl must be handled manually?
That's correct. We prefer to handle schema manually at Canonical,
and Storm reflects that.
> Furthermore, I noticed an example in the Storm tutorial which appeared to
> use raw SQL:
>
>>>> ruy.name = SQL("(SELECT name || ' Ritcher' FROM person WHERE id=4)")
Specifically *that* example isn't a good one, though. The intention
was showing precisely that you *can* write SQL in these cases, if you
want. You might write a similar statement using the provided
class-based expressions, or just assign a Python value to ruy.name,
of course.
> Is it possible with Storm, to generate SQL queries programatically,
> and in a database agnostic manner?
Yes, store.execute() can receive expression instances. Classes are
defined at storm/expr.py. Here is an example (will add to the
tutorial):
>>> result = store.execute(Select(Person.name, Person.id == 1))
>>> result.get_one()
(u'Joe Johnes',)
These expressions are used internally by Storm itself to
implement the ORM.
Regards,
--
Gustavo Niemeyer
http://niemeyer.net
More information about the storm
mailing list