CData Python Connector for Microsoft Teams

Build 24.0.9060

Querying Data

After connecting as described in Connecting, you can use the open connection to execute SQL statements.

Executing Queries

To execute SQL statements that return data, use the execute() method. Once a query is executed, the result set is fetched from the cursor. This result set can then be iterated over to process the records individually.

For example:

cur = conn.execute("SELECT subject, location_displayName FROM Teams")
rs = cur.fetchall()
for row in rs:
	print(row)

Parameterized Queries

Various Python collections, such as arrays and tuples, can act as additional arguments for the execute() method. This enables you to parameterize the queries executed and help to prevent SQL Injection.

For example:

cmd = "SELECT subject, location_displayName FROM Teams WHERE Id = ?"
params = ["Jq74mCczmFXk1tC10GB"]
cur = conn.execute(cmd, params)
rs = cur.fetchall()
for row in rs:
	print(row)

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060