2017-10-06 117 views
1

我有蟒蛇cx_Oracle executemany VS executemanyprepared

def insert_multi(connection, stmt, data): """ insert multiple records with executemany :param connection: cx_oracle connection :param stmt: prepared insert statement :param data: insert data :return: """ cur = connection.cursor() cur.prepare(stmt) cur.executemany(None, data) connection.commit() cur.close()

請問這個方法從cx_oracle方法不同的光標對象executemanyprepared這個功能呢? https://cx-oracle.readthedocs.io/en/latest/cursor.html

我該如何使用這種方法?

回答

1

遊標方法executemanyprepared()僅用於當您想要傳遞的數據已經包含在與遊標綁定的綁定變量中的已經時。通常這隻會在您從一個遊標中獲取並直接將該數據綁定到另一個遊標時發生。在所有其他情況下,調用傳遞數據的cursor.executemany()將是正確的解決方案。

希望能回答你的問題!