Posts filed under 'sqlalchemy'

Elixir: Good for What Ails You

Elixir, released today (Feb. 12), is a new declarative mapper for SQLAlchemy. Written by the authors of ActiveMapper and TurboEntity (the other two declarative mappers for SA), it intends to become a full-fledged extension to SQLAlchemy a la ActiveMapper. I downloaded version 0.1.0 today, and gave it a spin. Here are my thoughts.

Holy cow. This rules.

I could not have been more wrong in my belief that Python is a difficult language in which to write domain-specific languages. This is unbelievable - it rivals ActiveRecord, the best ORM I’ve tried.
Actually, in parts it improves on ActiveRecord, eliminating my pet peeve that I have to specify has_one and belongs_to methods (and their ilk) inside the model files instead of in the database schema, where I feel they should belong.


class Link(Entity):
has_field(’title’, Unicode(255))
has_field(’url’, Unicode(1023))
has_field(’saved_on’, DateTime)
has_and_belongs_to_many(’users’, of_kind=’User’, inverse=’links’)

Notice how it follows the active record pattern, despite being a declarative mapper. Note also how we no longer have to create endless secondary tables for many-to-many relationships, as we had to in bare SQLAlchemy and ActiveMapper. No more tedious assign_mapper statements for me.

Elixir is an unexpected gem - it’s powerful, concise, supports both declarative and active-record table declarations, has truly excellent documentation, and you don’t sacrifice a bit of the power that SQLAlchemy offers you in its querying syntax. Though I am no database administrator - and indeed, Elixir does not offer all the features of bare SQLAlchemy and support for legacy databases - I can see no reason to use any other ORM.

Stay tuned for next time, when I write about Quartz Compozer. (Speaking of which, can anyone find me a really juicy synonym for “infuriating”?)


3 comments February 13, 2007


About Me



I'm a college freshman, passionate about technology, programming (especially Cocoa and Python), and Apple.

By the way, 'important shock' is an anagram for 'Patrick Thomson'.

Meta

Links

Categories

Top Posts

Blog Stats