【发布时间】:2020-03-26 13:33:36
【问题描述】:
我的代码有什么问题,
with connect_db() as conn:
cursor = conn.cursor()
stmt = """INSERT INTO ip_records ip_address VALUES (%s)"""
try:
cursor.execute(stmt, (ip))
except mysql.connector.Error as err:
print err
return
我正在尝试将 ip 地址作为字符串插入 mysql 表。但是我收到了这个错误:
1064 (42000): 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 'ip_address VALUES (192.168.11.111)' at line 1
【问题讨论】:
-
应该是
(ip_address)?
标签: python mysql python-2.7 mysql-connector-python insert-statement