ODBC Driver for SendGrid

Build 23.0.8839

Parameterized Statements

The following code example shows how to bind parameters to create parameterized statements.

Single-Use Statements

The execute method accepts an additional sequence for binding query parameters to values.

cursor.execute("SELECT Title, Subject FROM MarketingCampaigns WHERE Id = ?", ("17693",))
for (Title, Subject) in cursor:
    print("Title = {}, Subject = {}".format(Title, Subject))

Multi-Use Statements

The executemany method can be used to execute the same query repeatedly with different sets of parameters. Instead of a sequence of parameters, executemany accepts a nested sequence of parameters which are used for each execution.

executemany works only with INSERT, UPDATE and DELETE statements. It cannot be used with any operation that returns results, such as a SELECT or an EXECUTE.

params = [
  ("March Top 50 football highlights. 1",),
  ("March Top 50 football highlights. 2",),
  ("March Top 50 football highlights. 3",),
]

cursor.executemany("INSERT INTO MarketingCampaigns (Subject) VALUES (?)", params)

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