CData Python Connector for Oracle Sales

Build 20.0.7745

Updating Data

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.oraclesalescloud as mod
conn = mod.connect("HostURL=https://my.host.oraclecloud.com; Username=abc123; Password=abcdef;")
cur = conn.cursor()
cmd = "INSERT INTO Opportunities (OptyId, Name) VALUES (?, ?)"
params = ["Commercial Oppty", "Residential Oppty"]
cur.execute(cmd, params)
print("Records affected: ", cur.rowcount)

Update

The following example modifies an existing record in the table:

import cdata.oraclesalescloud as mod
conn = mod.connect("HostURL=https://my.host.oraclecloud.com; Username=abc123; Password=abcdef;")
cur = conn.cursor()
cmd = "UPDATE Opportunities SET Name = ? WHERE Id = ?"
params = ["Residential Oppty", "300000002693011"]
cur.execute(cmd, params)
print("Records affected: ", cur.rowcount)

Delete

The following example removes an existing record from the table:

import cdata.oraclesalescloud as mod
conn = mod.connect("HostURL=https://my.host.oraclecloud.com; Username=abc123; Password=abcdef;")
cur = conn.cursor()
cmd = "DELETE FROM Opportunities WHERE Id = ?"
params = ["300000002693011"]
cur.execute(cmd, params)
print("Records affected: ", cur.rowcount)

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