文章详情页
python的MySQLdb库中的executemany方法如何改变默认加上的单引号?
问题描述
我需要创建上百个表,表名是:abc_1、abc_2、abc_3……之前用execute创建,觉得有些慢,于是现在考虑能不能用executemany,然后发现executemany会把参数用单引号括起来,
>>cur.execute(’’’create table %s (id int(10));’’’,(’abc_1’,))create table ’abc_1’ ( #单引号抛出异常>>cur.execute(’’’create table `%s` (id int(10));’’’,(’abc_1’,))create table `’abc_’` ( #创建成功,但创建的表名多出两个单引号
但是我们的库不允许用单引号括起来表名或字段名,导致直接报错。
问题解答
回答1:你把你语句create table %s (id int(10));中%s前后的符号去掉试试。
相关文章:
1. node.js - 怎么在初始化的时候使得一个子组件不加载?2. 代码如下,java用BigDecimal四舍五入怎么还有问题呀?哪种方式是完全没有问题的?3. angular.js - 请教angularjs里html和js通信的问题4. 求解决方法:Parse error: syntax error, unexpected5. 新人做网站求帮助6. java - mybatis里的REGEXP7. Linux服务器下怎么把phpStudy卸载干净8. 请问连接文件怎么写9. 没太明天这样写的作用10. mysql - thinkphp5 在MAC电脑本地正常,部署LINUX服务器之后,模型不存在
排行榜