[DB-SIG] Table Oriented Programming

Ian Bicking ianb at colorstudy.com
Sat Jan 29 21:13:47 CET 2005


Federico Di Gregorio wrote:
> Il giorno ven, 28-01-2005 alle 15:11 -0600, Ian Bicking ha scritto:
> 
>>It doesn't use bound parameters like ?, instead it does all the SQL 
>>generation itself including quotation.  So it has to know what database 
>>you are using to actually create the SQL, like "mysql", "postgresql", etc.
> 
> 
> This is.. er.. "horrible". PostgreSQL supports a *lot* of different
> types and the only way to support them all is to let the driver do the
> quoting (possibly with the user adding its own quoting rules, see
> PEP-246 adapt() in psycopg 2). I suppose your driver is not quoting
> PostGis or or even simple geometrical types mapped to Python instances,
> right?

No, but it could, as it has hooks for new types of data.  I'm not saying 
its the best technique, but then psycopg's technique isn't all that 
great either (falling back on __repr__ is particular bad, IMHO).

At some level sqlbuilder does its own SQL generation, that's the whole 
point of it.  The way it does it is fairly simple, there's a registry of 
converters, and also a __sqlrepr__ method that things like AND and 
expressions define which generates compound statements.  It would be 
good to use parameters, but it is a lot harder to keep track of those, 
which is why it hasn't happened yet.

-- 
Ian Bicking  /  ianb at colorstudy.com  / http://blog.ianbicking.org


More information about the DB-SIG mailing list