[DB-SIG] Oracle to Mysql (dates) Help please

arjen.dijkstra at hccnet.nl arjen.dijkstra at hccnet.nl
Sun Jan 11 10:19:11 EST 2004


Hi all,



I'm posting to this sig for the first time, i hope I'm doing this right.





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 DB-SIG mailing list