CData Python Connector for Oracle Sales

Build 20.0.7745

Updating Data with Sessions

Establishing a Session

After a mapping class is defined and a connection is established, the session is used to modify data in the available tables. The session is initially obtained by performing the below:

engine = create_engine("oraclesalescloud:///?HostURL=; Username=abc123; Password=abcdef;")
factory = sessionmaker(bind=engine)
session = factory()


First, define an instance of the mapped class, then add it to the active session. Call "commit()" on the session to push all added instances as inserted rows.

new_rec = Opportunities(Id="300000002693011", OptyId="Commercial Oppty", Name="Residential Oppty")


First, fetch the desired records with a filtered query. Then, modify the values of their fields and call "commit()" to update any records modified in this way.

modded_rec = session.query(Opportunities).filter_by(Id="300000002693011").first()
modded_rec.OptyId = "Commercial Oppty"
modded_rec.Name = "Residential Oppty"


First, fetch the desired records with a filtered query, then delete with the session. Call "commit()" to perform the delete operation with the provided rows.

removed_rec = session.query(Opportunities).filter_by(Id="300000002693011").first()

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