object-relational mappers

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Wed Apr 2 07:38:40 EDT 2008


Aaron Watters a écrit :
> I've been poking around the world of object-relational
> mappers and it inspired me to coin a corellary to the
> the famous quote on regular expressions:
> 
> "You have objects and a database: that's 2 problems.
> So: get an object-relational mapper:
> now you have 2**3 problems."
> 
> That is to say I feel that they all make me learn
> so much about the internals and features of the
> O-R mapper itself that I would be better off rolling
> my own queries on an as-needed basis without
> wasting so many brain cells.
> 
> comments?

If you're ok with building your queries as raw string and handling your 
resultsets as lists of tuples, then you're right, don't waste you brain 
cells learning anything else than SQL and the DB-API.

Now my own experience is that whenever I tried this approach for 
anything non-trivial, I ended up building an "ad-hoc, 
informally-specified bug-ridden slow implementation of half of " 
SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt 
at a better integration of SQL into Python. So while it may feel like 
learning the inner complexities of SQLALchemy (or Django's ORM which is 
not that bad either) is "wasting brain cells", MVHO is that it's worth 
the time spent. But YMMV of course - IOW, do what works best for you.






More information about the Python-list mailing list