Skip to content

Support for pyodbc.Cursor.execute with 0 or more parameters #1235

Closed Answered by gordthompson
CapAdv asked this question in Q&A
Discussion options

You must be logged in to vote
sql = "SELECT 1 AS foo"
crsr.execute(sql, None)

is equivalent to

sql = "SELECT 1 AS foo"
crsr.execute(sql, (None,))

which are both ways to pass a single parameter value of None (which maps to SQL NULL). To pass no parameters, simply use an empty tuple

sql = "SELECT 1 AS foo"
crsr.execute(sql, tuple())

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CapAdv
Comment options

Answer selected by CapAdv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1234 on June 20, 2023 13:19.