oodb philosophics ;) was: Re: [Zope-dev] Experiments with

Cees de Groot cg@cdegroot.com
11 May 2001 21:46:02 +0200


David Brown <ddb@namshub.org> said:
>But isn't Python a decent query language?  Isn't it nice to be able to have 
>all of the facilities of Python at your disposal when manipulating data, 
>rather than hoping that whatever database you are using doesn't have a 
>brain-damaged implementation of SQL?
>
Yup. Our business objects are sitting on top of my homebrew O/R mapping layer,
and I find myself entering the Python shell to do ad-hoc stuff with them more
and more often. Especially because stuff that repeats one or two times is
easily added as a method on the object for later reference...

One nice idea that should be possible in Pythonland as well: a Smalltalk O/R
mapping layer called GLORP uses Smalltalk as a query language in a very nice
way. Queries are given as Smalltalk blocks (say lambdas), and the mapping
layer interprets the block's parse tree in order to spit out equivalent SQL
code. Say:

Employees.get(lambda e: e.name[:3] == 'Foo')

to get all employees that have a name starting with "Foo".