Execute prepared statements with dynamic parameters returns a SQL syntax error.
import mariadb
|
|
db = mariadb.connect(host='localhost', user='test', password='test', database='test')
|
qr = db.cursor()
|
|
qr.execute('prepare TEST from "select ?, ?"')
|
|
# Works as expected
|
qr.execute('execute TEST using 100, 200')
|
records = qr.fetchall()
|
|
# Returns a syntax error
|
qr.execute('execute TEST using ?, ?', (50, 100))
|
# Traceback (most recent call last):
|
# File "<stdin>", line 1, in <module>
|
# mariadb.ProgrammingError: You have an error in your SQL syntax; check the manual that # corresponds to your MariaDB server version for the right syntax to use near '?, ?' at line 1
|
|
# Same error with %s
|
|
qr.execute('deallocate prepare TEST')
|
db.close()
|