Nicolas Lehuen wrote:
2005/6/17, David Fraser <[EMAIL PROTECTED]>:

I don't know how it could be made good performance-wise, but it would be
great to have a generic database session store that you could pass a
Python DB-API connection object to. Of course, that would be difficult
to configure in the same way as the other session objects, but lots of
apps have already got a database connection open...

David



Alas, programming in a DBMS-neutral way is not that easy in Python.
Granted, the DB-API is standard for all its implementors, but the SQL
resquest (be it DQL, DML or DDL) is usually DBMS-specific. And the
fact that parameters escaping can be made in one of five ways (see
paramstyle in http://www.python.org/peps/pep-0249.html) is not very
helpful here.

So, writing a DBMS-neutral connection pool is feasable. Writing a
DBMS-specific session store is feasable. But writing a DBMS-neutral
session store is a bit of work.


Probably the best way would be to have a SQLSession class that would be sub-classed for the specific DBMS, provide one or two common subclasses such as MySqlSession(SQLSession) and then leave it up to users to create their own subclasses for other DBMS. There differences between DBs is small enough that creating the subclasses should be trivial.

Jim

Reply via email to