473,722 Members | 2,368 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 2060

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 02   error_reporting(E_ALL);
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 del database "SAMPLE" non è stato trovato. SQLSTATE=42705.
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 code which is followed by importing data to tables and subsequent append queries to other tables....
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, however, is all the useful things you could do to automatically maintain a back-end database from a...
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 add the if (PEAR::isError($db)) { die($db->getMessage());} code, so not the connection... Then 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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 most users, this new feature is actually very convenient. If you want to control the update process,...
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
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 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.