473,563 Members | 2,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(da tabase="templat e1")
cu = c.cursor()
o = pgdb.Time(10, 0, 0)
cu.execute("sel ect %(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.executeman y(operation, (params,))
File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 201, in
sql = _quoteparams(op eration, params)
File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 283, in
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.InterfaceE rror: do not know how to handle type <type 'instance'>

This doesn't happen for strings or numbers:
cu.execute("sel ect %s;", ['s'])
cu.execute("sel ect %s;", [1])
cu.execute("sel ect %(k)s;", {'k': 123})
o <DateTimeDelt a object for '10:00:00.00' at 401e8a48>

Thus, pgdb doesn't know how to handle DateTimeDelta.

The same with
cu.execute("sel ect %(o)s;", {'o': pgdb.Date(2005, 1,1)})

. . .
line 201, in executemany
sql = _quoteparams(op eration, 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.InterfaceE rror: do not know how to handle type <type

(It was after I commented out exception catch:

# except:
# raise OperationalErro r, "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?

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 2054

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

Similar topics

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 now closes the database connections of _all_ database objects. I ask myself if this is intentional or a bug. Below a code example: 01 <?php...
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 recent call last): File "./db.py", line 41, in ?
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
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 "restaurant" database does exist. Where should I start looking? PHP 5.0.4 / mySQL 4.1.13-nt / IIS / XP Pro
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'è scritto : "Gli alias "SAMPLE" del database già esistono nel catalogo database locale o di sistema. SQL1013N Il nome alias di un database o il nome...
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 : "SQL1478W The defined buffer pools could not be started. Instead, one small
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 say this is the auto number fields are NOT being reset to zero. I delete the data from tables with action delete queries, then call the compact DB...
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 it though table links. I am comfortable with the data side of things (whether through table links or an adodb.recordset). What I am missing,...
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 for the database connection. the problem is that it don't works, actually the php don't writes anything in the table and i don't get any error when i...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.