[clug] Python & databases

Hal Ashburner hal.ashburner at gmail.com
Mon Feb 22 00:47:25 MST 2010

On 22/02/2010 6:29 PM, Brendan Jurd wrote:
> On 22 February 2010 18:12, Hal Ashburner<hal.ashburner at gmail.com>  wrote:
>> On 22/02/2010 5:44 PM, Brendan Jurd wrote:
>>> The idea of dbapi is to provide an API that is consistent regardless
>>> of which driver you're using, so I'm not sure what you're driving at
>>> when you say "seems fairly backend specific".  In what sense?
>> In the sense that there is so much discretion left to the implementation
>> that the interface will never be consistent between different backends.
>> Casts are not handled the same way between back ends,  sqlite3 uses
>> different place holders to psycopg2 (eg  ? vs %s)... and so on.
>> Either I'm reading it wrong or there doesn't seem to be a good way of doing
>> very simple things and making it work with both backends. ie, nothing you
>> list below, the resulting sql should be the same.
> Right, I'm with you now.  The paramstyle thing is unfortunate.
> To solve that problem, how about writing a little bit of Python to
> interrogate the paramstyle [1] of the database driver you happen to be
> using and put the appropriate parameter markers into your SQL?
> I realise it's not a beautiful solution, but it'll do the job.
It's more than just paramstyle from what I'm seeing.
So the solution is to abstract away the database abstraction for the 
different back ends.
Ok so yeah so this is sub-optimal and a bit fugly and it's what's been 
done in this code.
Would ODBC be a better solution here? Has anyone tried anything else 
than abstracting the abstraction to make it do what it's supposed to do 
in the first place?

More information about the linux mailing list