[DB-SIG] Table Oriented Programming
mal at egenix.com
Fri Jan 28 19:45:36 CET 2005
Brad Clements wrote:
> On 12 Feb 2004 at 13:10, Michael Hobbs wrote:
>>Consider this example code:
>> departments = DepartmentTable
>> employees = EmployeeTable
>> johnsDepartment = (departments * employees) /
>> (employees.dept == departments.dept) /
>> (employees.name == 'John') %
>> print johnsDepartment.name
> Has anyone tried expressing sql operations as relational algebra statements in Python,
> like the example above.
> I see lots of talk in google, but no code.
> Is this idea out of fashion already? I can see lots of performance issues.. but it's still
> interesting to me.
FWIW, SQLObject has some logic in place which mimics some of these
In general, I think you could work out a "compiler" which generates
SQL from the expression - you'd only need to define a set of special
objects that build a logical representation of the expression by
using the various hooks (__add__, __sub__, etc.).
I don't see any big performance issues, BTW, since you're basically
writing SQL in a slightly different way.
Professional Python Services directly from the Source (#1, Jan 28 2005)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the DB-SIG