CData Python Connector for Office 365 2019 - Online Help
Questions / Feedback?

Updating Data

CData Python Connector for Office 365 2019 - Build 19.0.7416

The connection's cursor object is used to issue INSERT, UPDATE, and DELETE commands to the data source. If desired, parameters are used with these statements. Unlike many python connectors, this connector does not support transactions. Consequently, any SQL statements executed by this connector affect the data source immediately. So, the commit() method on the connection object should not be used.

Insert

The following example adds a new record to the table:

import cdata.office365 as mod
conn = mod.connect("InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;")
cur = conn.cursor()
cmd = "INSERT INTO Events (Id, location_displayName) VALUES (?, ?)"
params = ["Town Hall Grille", "Zenburger"]
cur.execute(cmd, params)
print("Records affected: ", cur.rowcount)

Update

The following example modifies an existing record in the table:

import cdata.office365 as mod
conn = mod.connect("InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;")
cur = conn.cursor()
cmd = "UPDATE Events SET location_displayName = ? WHERE Id = ?"
params = ["Zenburger", "Jq74mCczmFXk1tC10GB"]
cur.execute(cmd, params)
print("Records affected: ", cur.rowcount)

Delete

The following example removes an existing record from the table:

import cdata.office365 as mod
conn = mod.connect("InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;")
cur = conn.cursor()
cmd = "DELETE FROM Events WHERE Id = ?"
params = ["Jq74mCczmFXk1tC10GB"]
cur.execute(cmd, params)
print("Records affected: ", cur.rowcount)

 
 
Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 19.0.7416.0