Skip to content
Advertisement

Load table from Oracle to MYSQL using python

Tried below code to load rows from Source(Oracle) to Target(MYSQL)

Error

Edited Updated Code_:-

Error:

Advertisement

Answer

In Python, while all strive to adhere to PEP 249, no two DB-APIs are exactly the same especially in parameter implementation. Specifically, while the module, cxOracle, supports arbitrary placeholders like numbered sequence :1, :2, :3, etc. the module MySQLdb only supports %s or%(name)s parameter style.

Therefore, adjust prepared SQL statement accordingly. Additionally, consider format to dynamically write placeholders via a list (["%s", "%s", %s", ...]) to avoid long unnumbered write-out and executemany to avoid looping.

But if you were using a loop, simply pass the row itself and not unpack each of its elements or use indexing to needed point:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement