Skip to content Skip to sidebar Skip to footer

Does Pyodbc Support Any Form Of Named Parameters?

I know sqlite3 has data = {'test_col': 012345679} sqlite3_conn.execute(''' UPDATE test_db SET test_col = :test_col ;''', data) and mysql-connector-python has data = {'test

Solution 1:

It doesn't support named parameters, but bound parameters passed in the correct order are fairly straightforward:

x = "This"
y = 345

mssql_cur.execute("SELECT * FROM mytable WHERE colx = ? AND coly = ?", x, y)

or

mssql_cur.execute("SELECT * FROM mytable WHERE colx = ? AND coly = ?", (x, y))

More details and options here, such as passing executemany parameters:

https://github.com/mkleehammer/pyodbc/wiki/Cursor

Good luck!

Post a Comment for "Does Pyodbc Support Any Form Of Named Parameters?"