python语句:
values = [('a',28),('b',29)]
sql = """insert into test(name, age) values(%s, %s)"""
cur.executemany(sql,values)其中name字段为varchar,age字段为int型。报错:
Mysql Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s, %s),
(%s, %s)' at line 2请问错误中怎么会出现'%s, %s),(%s, %s)'的,语句里面只有(%s, %s)。
是不是编码相关的问题,python跟MySQL都是用的utf8编码。
values = [('a',28),('b',29)]
sql = """insert into test(name, age) values(%s, %s)"""
cur.executemany(sql,values)其中name字段为varchar,age字段为int型。报错:
Mysql Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s, %s),
(%s, %s)' at line 2请问错误中怎么会出现'%s, %s),(%s, %s)'的,语句里面只有(%s, %s)。
是不是编码相关的问题,python跟MySQL都是用的utf8编码。
解决方案 »
- mysql数据用excel导出怎么是乱码,有什么解决的方法吗?
- mysql同步创建表的问题
- mysql中如果设置了id自增的问题
- 没分了,只求好心人,我在mysql控制台上输错了命令,请问怎么返回mysql>目录啊?
- mysql 命令行下如何建存储过程(或继行)
- 请教怎样用text文本为表导入数据
- 最菜问题,想搞清楚SQL概念的说……
- 如何判断表中是否存在某个字段
- 一个简单的建表存储过程,执行没有错误,但是没有新表生成
- mysql-5.7.10-winx64 在配置文件[mysqld]下加入 skip-grant-tables还是出现ERROR1045
- mysql Cluster 各个部分的作用是什么 在等大侠
- MySQL Workbench 不能连接数据库服务器
data = [
('Jane', date(2005, 2, 12)),
('Joe', date(2006, 5, 23)),
('John', date(2010, 10, 3)),
]
stmt = "INSERT INTO employees (first_name, hire_date) VALUES (%s, %s)"
cursor.executemany(stmt, data)
看起来用法是一样的啊
print sql