Oracle to Mysql, I'm (still) lost...

Marc Boeren M.Boeren at guidance.nl
Mon Jan 19 07:44:11 EST 2004


Hi,

instead of

>     cursMy.execute("insert into %s values %s", (tabel, a_oracle))

Try:

sql = "insert into "+ tabel +" values ("
comma = ""
for value in a_oracle:
    sql+= comma + "%s"
    comma = ", "
sql+= ")"

or better:

sql = "insert into %s values (" % tabel
sql+= ", ".join(["%s"] * len(a_oracle))
sql+= ")" 
cursMy.execute(sql, a_oracle)

which does the same thing.

Your original sql-statement looked (for the execute call) like it needed two
(sql-style)parameters, when in fact it needs as much parameters as there are
fields in the table. And, the table-name is not an sql-parameter, it is just
something that needs filling in...

Hope this helps,

Cheerio, Marc.




More information about the Python-list mailing list