473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

DB-API 2.0 in pysqlite and pgdb


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
--
rn*@onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
Jul 18 '05 #1
0 2043

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sven Jacobs | last post by:
Dear newsgroup, I've upgraded to PEAR::DB 1.6.5 recently. Unfortunately now the database connection doesn't work as expected anymore :( The problems seems to be the method disconnect(), which...
2
by: Oliver Peek | last post by:
Hi all, Probably my fault, I'm opening a Berkeley DB file, iterating through and deleting keys, well making an attempt. I get this error when I try to delete. ---error Traceback (most...
7
by: martijn | last post by:
WHen I use the code below and printing all the results i get this: ------ 0 1 10 11 2 3 4 5 6 7 8 9 ------ But I want ------ 0 1 2
5
by: lwoods | last post by:
When I execute the following script I can connect using 'mysqli_connect' but I get a "DB Error: Not Found" when I display the $db->Message() after attempting the DB::Connect. And, "yes", the...
5
by: Ale | last post by:
Ciao a tutti. Ho eliminato il database di esempio SAMPLE(non cancellato). Ora lo voglio reinstallare ma durante l'installazione mi da il seguente errore: nella finestra con scritto SQL1005N c'č...
22
by: Smutny30 | last post by:
Hello, I am preparing a database that will store 10 n * GBs - 100 n * GBs of data. I calculated to have 1,2 GB of bufferpools. I run the DB2 v. 8.2.1 alone on 4 GB box. I obtain : ...
2
by: Greg Strong | last post by:
Hello All, I've written code in a test database with test data. Everything seems to be working except compact database in VB code per http://www.mvps.org/access/general/gen0041.htm. The reason I...
2
by: Sam Shaw | last post by:
I have been looking after an MS Access database, using table links to access data in a back-end MDB database. We have recently micrated to a SQL Server 2000 back-end atabase, once again accessing...
2
by: daralthus | last post by:
Hello! I would like to ask your help, i have founded a great code here: http://www.jamescaws.co.uk/2008/07/dynamically-count-exit-link-clicks-throughs-using-javascript-php/ but it uses Pear DB...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.