mysql not enough arguments__mysql_exceptions.ProgrammingError: not enough arguments for format strin...

一、描述

执行python脚本,报如下错误

insert into r_hour_stat_dsp ( day,hour,test,country_code,advertiser_id,order_id,ad_id,mid,publisher_id,app_id,traffic_source,slot_id,bucket_id,up_request_count ) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) on duplicate key update up_request_count=Values(up_request_count)

[{'up_request_count': Decimal('61'), 'bucket_id': 'total', 'ad_id': 'a2829410199104', 'hour': 20L, 'order_id': 'o2823322169152', 'traffic_source': 'total', 'mid': 'm2829410199169', 'app_id': 'app263722909504', 'advertiser_id': 'adv2823318381440', 'slot_id': 's1967610014720', 'country_code': 'CH', 'test': 0L, 'publisher_id': 'pub236088034304', 'day': 20200524L}]

Traceback (most recent call last):

File "adx_dsp.py", line 88, in

run(cond_str)

File "adx_dsp.py", line 67, in run

dsp_dim_statistics(official_conn,"r_hour_stat_dsp",cond_str)

File "adx_dsp.py", line 58, in dsp_dim_statistics

conn.execute_many(insert_sql,data[x*BATCH_DELETE_COUNT:(x+1)*BATCH_DELETE_COUNT])

File "/home/sdev/liujichao/py_lib/db.py", line 85, in execute_many

affect_row_num = cursor.executemany(sql, param)

File "/home/sdev/liujichao/MySQLdb/cursors.py", line 253, in executemany

self.errorhandler(self, ProgrammingError, msg.args[0])

File "/home/sdev/liujichao/MySQLdb/connections.py", line 36, in defaulterrorhandler

raise errorclass, errorvalue

_mysql_exceptions.ProgrammingError: not enough arguments for format string

二、分析

1、如上,为啥报错,%s的个数与参数的个数是一样的

三、解决方法

execute_many(insert_sql,data) data只能是tuple类型(

注意:本文归作者所有,未经作者允许,不得转载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值