473,320 Members | 1,957 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,320 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
how....
Jul 18 '05 #1
0 1568

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

Similar topics

0
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 will do fine. 1. PHP includes a native ODBC...
6
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 ) - Linked Tables to SQL-Server 2000 over ODBC I used...
2
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 don't get an erro What am I doing wrong (or for...
3
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 4.0.15. I have MySQL running with new tables...
2
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 MS Access. This was all done via an User DSN...
1
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 evolved and been a solution to collect data but now...
1
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 work. The program uses foxpro dbases (version 3) for...
0
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 install of Sage Line 50, is an ODBC driver. I...
0
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 colon (:). In ODBC :<foo> indicates the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.