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

From Pandas

CData Python Connector for Office 365 2019 - Build 19.0.7416

When combined with Pandas' DataFrames, the connector is used to generate numerous different graphics for the purpose of analytics.


In order to use Pandas it will need to be imported. Pandas will also rely on a SQLAlchemy engine when executing queries, as below:

import pandas as pd
from sqlalchemy import create_engine
engine = create_engine("office365:///?InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;")

Querying Data

SELECT queries are provided in a call to the "read_sql()" method in pandas, alongside a relevant connection object. Pandas will execute the query on that connection, and return the results in the form of a DataFrame, which are used for a variety of purposes. In order to use pandas, it will need to be imported:

df = pd.read_sql("""
	FROM Events;""", engine)

Modifying Data

To insert new records to a table, simply create a new DataFrame, and define its fields accordingly. From there, simply call "to_sql()" on the DataFrame to perform the INSERT operation with the connector, as in the below example. The "if _exists" argument must be set to "append" to prevent pandas from attempting building the table from scratch:

df = pd.DataFrame({"Id": ["Town Hall Grille"], "location_displayName": ["Zenburger"]})
df.to_sql("Events", con=engine, if_exists="append")

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