Oracle to Mysql (dates) Help please

duikboot ad at ad.nl
Sun Jan 11 14:31:33 CET 2004


Hi all,

I'm trying to export a view tables from a Oracle database to a Mysql
database.  I create insert statements (they look alright), but it all goes
wrong when I try to execute them in Mysql, because the dates must have
quotes on each side.
I just don't know how make the dates right.
Well I'll just show you the code and some insert statements it generates.
Could anyone please help me?

Thanks,

Arjen

####Code####

import cx_Oracle
tabellen=["machine"]
con_oracle=cx_Oracle.connect("bla/bla")
c_oracle=con_oracle.cursor()

import MySQLdb
my=MySQLdb.Connect("localhost", db="bla")
my_mysql=my.cursor()
for tabel in tabellen:
    print tabel
    c_oracle.execute("select * from %s" % tabel)
    a_oracle=c_oracle.fetchone()
    #file=open("%s.sql" % tabel, 'w')
    while a_oracle != None:
        b=str(a_oracle)
        ins="insert into %s values %s;\n" % (tabel, b)
        #file.write(ins)
     my_mysql.execute(ins)
        #print ins

        a_oracle=c_oracle.fetchone()
    file.close()

con_oracle.close()

my.close()


##insert statement###

insert into machine values ('230KM', ' ', '230KM', 1980-01-01 00:00:00,
2035-01-01 00:00:00, 1, 100, 'asap', 'NO', 0, 0, 'corrugator', 2003-12-04
06:00:00, 1970-01-01 01:00:00, ' ', 'normal', 0.0, 0.0, 7, ' ', ' ',
'normal', ' ', ' ', 'A', 2003-12-04 09:42:14, 82766);





More information about the Python-list mailing list