Версия python 3.11, версия pyodbc 5.2.0
Функция не работает:
def test_parametr_sql():
from pyodbc import connect
p = ("xxx", "xxx", "xxx", "xxx")
s = """Driver={0};Server={1};Database={2};UID={3};Password={4};Option=3;charset=UTF8;
""".format('{MySQL ODBC 8.0 UNICODE Driver}', p[0], p[1], p[2], p[3])
try:
con = connect(s, autocommit=True)
except Exception as e:
print("Ошибка подключения Mysql %s, %s" % (s, e))
curs_to = con.cursor()
tbl_to = "oc_information_description"
curs_to.execute(f"TRUNCATE TABLE {tbl_to}")
sql = """
INSERT INTO oc_information_description
('information_id', 'language_id', 'title', 'description')
VALUES (%s, %s, %s, %s)
"""
data = [9, 1, 'Правила партнёрской программы', 'xxx']
curs_to.execute(sql, data)
ошибка
pyodbc.ProgrammingError: ('42000', "[42000] [MySQL][ODBC 8.0(w) Driver][mysqld-5.5.5-10.1.48-MariaDB]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 ''information_id', 'language_id', 'title', 'description') \n VALUES (%s, %s, %s' at line 2 (1064) (SQLPrepare)")