ODBC and date 
Author Message
 ODBC and date

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 ?

    Thanks a lot




Thu, 27 Nov 2003 18:27:49 GMT  
 ODBC and date

Quote:
> 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"



Sat, 29 Nov 2003 19:11:47 GMT  
 ODBC and date

Quote:



> > 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 ?

MySQL uses an ISO <some magic number> format date. I have been using Marc
 Lemburg's ODBC driver which is very good (http://www.lemburg.com/python) and
found that when using dates if it's necessary to set the dateformat for the
cursor:

db = Connect(dsn, user, pwd)
c = db.cursor()    
c.datetimeformat=3

There are constants for the date formats so you can interpret the date in
many ways.

David



Sun, 30 Nov 2003 19:54:39 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. TPS ODBC and Date Fields in Crystal Reports?????

2. Beta TPS ODBC (long) Date conversion ?

3. Topspeed ODBC Driver Date Problem

4. DATE vs LONG in .tps files and ODBC

5. CW Browse Template Date Range & ODBC

6. Date Format with ODBC

7. TPS ODBC Date Problem

8. HELP: SQL ODBC date range, 2nd post

9. ODBC - Date Time

10. ODBC driver and Date fields

11. ODBC Date Time Format

12. TopSpeed ODBC Date Translation: Example?

 

 
Powered by phpBB® Forum Software