472,351 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

ODBC & DbiData problem

I have a problem for experienced programmers. The following code
should copy data between two different databases:

import dbi,odbc
conn1=odbc.odbc('mysql'); conn2=odbc.odbc('sqlite')
c1 = conn1.cursor(); c2 = conn2.cursor()

c1.execute("SELECT field1, field2 FROM table1")
rows = c1.fetchall()
c2.executemany('INSERT INTO table1 (field1=%s,field2=%s)', rows)

c1.close();c1=None; c2.close();c1=None;
conn1.close();conn1=None; conn2.close();conn2=None

The problem is: field 'field2' is DATE type and after fetchmany()
method I got DbiDate object instead of string 'YYYY-MM-DD
HH:MM:SS'. So my code breaks because Python cannot
insert such object to another database.

I know how to convert this object to the correct string
(http://www.python.org/windows/OdbcHints.html) but it must be done for
every field in every row. :( So my question is: Is it possible to make
odbc module to *automatically convert* this field from DbiDate object
to string? Maybe is there any special parameter to set up? I do not
want to write special code to convert all such fields. It suppose, it
can be done more automatically by odbc module, bu I do not know
Jul 18 '05 #1
0 1531

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

Similar topics

by: Bob | last post by:
OK, PHP newbie here, did a search, but I can't see the forest for the trees now. I need a sanity check to see if I've got this right. Short answers...
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) -...
by: mekim | last post by:
Hi All Sometimes when I have a database open in access I get an error when trying to use the same access database w/ ODB and othertimes....i...
by: Steve Farber | last post by:
I'm not especially new to databases and I have used ODBC before with other data sources, but I cannot seem to get Access 2003 to talk to MySQL...
by: David | last post by:
Hi, I have an MS Access database in which the tables have been exported to a MySQL DB on a Cobalt Qube 3 server and then import linked back into...
by: Paul | last post by:
Hello, I am converting an Access database on our network to a sql 2000 backend and keeping access as the front end. The access database has...
by: Derek Griffiths | last post by:
Most of the complicated programs I write are boring applications that manipulate databases associated with the medical billing program where I...
by: marc.holt | last post by:
Please help! I am attempting to extract data from a Sage Line 50 database ( .dta extention) via an ODBC connection. Included in the application...
by: Justin Cave | last post by:
"Chris Blair" <chris_w_blair@yahoo.com.uk.zzwrote in message news:<bhvk6a$mpf$1@nobel2.pacific.net.sg>... My guess is that you're not escaping the...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.