Happy New Year to all Pythoneers! I am playing with pysqlite and pgdb and their DB-API conformancy. It was quite interesting to know:
- sqlite doesn't have mandatory helper-functions Date, Tim, etc. (due to an error int it's __init__, but this is quite obvious to correct or just to use mx.Date, mx.Time) more serious mishaps with pgdb (postgresql-python): it doesn't know how to quote date-time data for the objects it has constructors itself. >>> import pgdb >>> c = pgdb.connect(database="template1") >>> cu = c.cursor() >>> o = pgdb.Time(10, 0, 0) >>> cu.execute("select %(o);", vars()) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 189, in execute self.executemany(operation, (params,)) File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 201, in executemany sql = _quoteparams(operation, params) File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 283, in _quoteparams x[k] = _quote(v) File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 275, in _quote raise InterfaceError, 'do not know how to handle type %s' % type(x) pgdb.InterfaceError: do not know how to handle type <type 'instance'> This doesn't happen for strings or numbers: >>> cu.execute("select %s;", ['s']) >>> cu.execute("select %s;", [1]) >>> cu.execute("select %(k)s;", {'k': 123}) >>> o <DateTimeDelta object for '10:00:00.00' at 401e8a48> Thus, pgdb doesn't know how to handle DateTimeDelta. The same with >>> cu.execute("select %(o)s;", {'o': pgdb.Date(2005,1,1)}) . . . line 201, in executemany sql = _quoteparams(operation, params) File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 283, in _quoteparams x[k] = _quote(v) File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 275, in _quote raise InterfaceError, 'do not know how to handle type %s' % type(x) pgdb.InterfaceError: do not know how to handle type <type 'DateTime'> (It was after I commented out exception catch: # except: # raise OperationalError, "internal error in '%s'" % sql in pgdb.py to see where the error occurs) Am I missing something obvious or is it really a bug/feature of pgdb? python2.3 postgresql-7.2.1 almost fresh mx.DateTime Thank you! Sincerely yours, Roman Suzi -- [EMAIL PROTECTED] =\= My AI powered by GNU/Linux RedHat 7.3 -- http://mail.python.org/mailman/listinfo/python-list