文章详情页
python的MySQLdb库中的executemany方法如何改变默认加上的单引号?
浏览:124日期:2022-07-21 16:40:34
问题描述
我需要创建上百个表,表名是: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. angular.js - ng-grid 和tabset一起用时,grid width默认特别小2. css - transform-origin 旋转参考点3. python - pyspider爬取了接近1G的数据,无法导出csv?4. python for循环中的函数只能运行一次?5. python的文件读写问题?6. html5 - 在一个页面中 初始了两个swiper 不知道哪里错了 一直不对7. 能用Nginx服务小型购物网站的web吗?8. selenium-基于python2-126邮箱登陆问题9. android - 美团筛选处筛选条件停靠+条件点击滑动到顶部。10. 请问是对象还是数组
排行榜
