CData Python Connector for kintone

Build 21.0.7930

Batch Processing

This python connector is also able to perform batch processing to write to the data source. This can be done by using the executemany() method of the cursor object. In addition to a SQL statement string, a data frame of values should be provided as a series of parameters to execute the SQL statement with. as with normal write operations, the statements are executed immediately by the provider. Do not call the connection's commit() method following the execution.

Insert

The following example adds new records to the table:

cur = conn.cursor()
cmd = "INSERT INTO Comments (CreatorName, Text) VALUES (?, ?)"
params = [["Old to do", "New to do"], ["Old to do", "New to do"]]
cur.executemany(cmd, params)
print("Records affected: ", cur.rowcount)

Update

The following example modifies existing records in the table:

cur = conn.cursor()
cmd = "UPDATE Comments SET Text = ? WHERE Id = ?"
params = [["New to do", "123456"], ["New to do", "123456"]]
cur.executemany(cmd, params)
print("Records affected: ", cur.rowcount)

Delete

The following example removes existing records from the table:

cur = conn.cursor()
cmd = "DELETE FROM Comments WHERE Id = ?"
params = [["123456"], ["123456"]]
cur.executemany(cmd, params)
print("Records affected: ", cur.rowcount)

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930