PDO and database abstraction

Gerhard Häring gh at ghaering.de
Tue Oct 25 14:20:35 CEST 2005

Luiz Geron wrote:
> Hi all,
> I'm testing the PDO wrapper to database modules [1] and I'm wondering
> how few things like this there are around. 

Actually there are several Object-Relation Mappers (ORM) for Python, and 
also a few other attempts to provide a more convenient layer on top of 
DB-API modules.

This wiki page has links: 

> My problem, actually, is the paramstyle of modules.

That problem exactly what these solutions try to solve, this and 
multiple SQL dialects and handling types like date etc. for multiple 

> I want to use kinterbasdb in the same code I use
> cx_oracle, for example, but paramstyle changes from one to other, than
> I searched for things like this and found nothing really usefull. The
> problem with PDO is that it was so dificult to find, since a few people
> seems to use it,  and I haven't yet figured how to change the paramstyle
> on it, so I want to ask: Do you use a thing like this that you would
> recommend to me?

I always wrote my own thin layer on top of DB-API modules and used it to 
implement a *specific* database interface for my applications. This 
would then have one or more database backends. Actually never more than 
two so far.

If you want to go for a more popular ORM, you can try out SqlObject. But 
  it doesn't have Oracle support, yet. There were patches and there are 
apparently again new attempts to integrate Oracle support, but nothing 
official/finished yet apparently.

Personally, I recently checked out different ORMs for Python one 
afternoon. Only superficially, but here's my biased uninformed opinion.

- SqlObject (1) has an active community, and its use in Subway and
TurboGears will create even more momentum for it. By looking at its code
(for hacking in Oracle support, which I managed to do for a one-table
test case), I found it to have *a lot* features, including caching and
others. I don't particularly like that, I'd prefer a thin-to-medium
layer myself.

- There was something to Modeling (2) I didn't like. It's just a gut 
feeling that it tries to do too much for my taste.

- PyDO2 did work with Oracle out of the box, the SQLite and PostgreSQL 
adapters looked reasonable too from a quick code inspection. It does 
seem to do one thing and do it right, which is a philosophy I like in 
libraries and wrappers. If I'm to use a ORM for a future project, I'd 
first go with PyDO2.


-- Gehard

(1) http://sqlobject.org/
(2) http://modeling.sourceforge.net/
(3) http://skunkweb.sourceforge.net/PyDO2/manual.html

More information about the Python-list mailing list