[DB-SIG] OO wrapper for SQL?

Tom Bryan tbryan@starship.beopen.com
Wed, 28 Jun 2000 18:38:30 -0700 (PDT)

On Tue, 30 May 2000, oivvio polite wrote:

> A few hundred lines of that can make one somewhat dizzy.
> What I'd want to have instead is a somekind of oo wrapper for sql,
> probably something working on top of the python db api. Something that
> would let my say:
> oldtable1 = dboo.table.existing(connection,database,tablename1)
> oldtable2 = dboo.table.existing(connection,database,tablename2)
> newtable =  dboo.table.join(newtablename, oldtable1, oldtable2,
> some_condition)
> This would take a couple of old tables in the my database join them
> whith some condition and insert the result as a new table in the
> database.

I suppose you could read up on the relational algebra underneath SQL.  You
could provide your own access to joins, projections, etc.  Another
strategy is to implement some sort of data access layer that handles all
data retrieval.  I know some people have had success with the delegation
pattern to isolate a persistence layer.

> Of course there should be tons of other possible operations. I want to
> be able to do pretty much everything I can do with sql, without having
> to maintain that horrible sql code.

A good understanding of relation algebra would be a good start.  Then
you'll basically be translating your calls to the SQL equivalent.   

> Have you seen anything like this for python, or maybe in for some
> other language?

I don't think that I've seen anything like you're doing, but there are
many different ideas about how to provide access to data in a database in
a clean, object-oriented manner.  I haven't done much reading, but I think
that Microsoft has DAO and ADO specifications and Java has some stuff on
doing this with enterprise beans (components),

You might also want to look into how object-oriented databases provide
access to data if they're not using SQL.