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

Updating Data with Sessions

CData Python Connector for Office 365 2019 - Build 19.0.7416

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("office365:///?InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;")
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 = Events(Id="Jq74mCczmFXk1tC10GB", Id="Town Hall Grille", location_displayName="Zenburger")


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(Events).filter_by(Id="Jq74mCczmFXk1tC10GB").first()
modded_rec.Id = "Town Hall Grille"
modded_rec.location_displayName = "Zenburger"


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(Events).filter_by(Id="Jq74mCczmFXk1tC10GB").first()

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