CData Python Connector for Pinterest

Build 20.0.7745

Querying Data

After connecting with the steps in Connecting, you can execute a SQL statements using the connection's cursor object.

Executing Queries

To execute SQL statements that return data, use the cursor object's 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:

import cdata.pinterest as mod
conn = mod.connect("InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='https://localhost:33333'")
cur = conn.cursor()
cur.execute("SELECT Id, Username FROM USERS")
rs = cur.fetchall()
for row in rs:
	print(row)

Parameterized Queries

Various python collections, such as arrays and tuples are provided as additional arguments for the execute method. This allows you to parameterize the queries executed and help to prevent SQL Injection:

import cdata.pinterest as mod
conn = mod.connect("InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='https://localhost:33333'")
cur = conn.cursor()
cmd = "SELECT Id, Username FROM USERS WHERE Column2 = ?"
params = ["Bob"]
cur.execute(cmd, params)
rs = cur.fetchall()
for row in rs:
	print(row)

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