ODBC and date

Steve Holden sholden at holdenweb.com
Tue Jun 12 07:11:47 EDT 2001


"Maurice HUET" <m.huet at online.fr> wrote in message
news:FYHU6.106$GJ3.438333 at nnrp3.proxad.net...
> Hello,
>
>     I want transfert data from a progress database to a MySql database
with
> python and the ODBC module. (Win plateform)
>     How can I specify date selection in the SQL order ?
>     The date data cause problem (dbidate type) when i want write tem in a
> text file between then two database ?
>
>     Someone have a solution ?
>
Had you thought of writing one program that connects to both databases? It
is then relatively easy to transfer data from one to the other. Here's some
code which creates a Gadfly database from an ODBC source, doesn't use dates
but it might get you started. Two ODBC sources should be no more
difficult...

regards
 Steve

#
# Create the gadfly database from the "Webdata" ODBC source
#
import gadfly
import odbc

ocn = odbc.odbc("Webdata")
ocu = ocn.cursor()

gcn = gadfly.gadfly()
gcn.startup("webdata", "gadfly")
gcu = gcn.cursor()

gcu.execute("create table PgData (PgName varchar, PgNum integer, PgText
varchar)")
ocu.execute("select PgName, PgNum, PgText from PgData")
gcu.execute("insert into PgData (PgName, PgNum, PgText) values (?, ?, ?)",
                ocu.fetchall())
gcn.commit()

for obj in (gcu, ocu, gcn, ocn):
    obj.close()

print "gadfly database created"





More information about the Python-list mailing list