3
回答
大家好,插入数据有问题但找了一天,也没有找出是什么原因

大家好,插入数据有问题但找了一天,也没有找出是什么原因,下面是源码

#-*- coding: utf-8 -*-
import sys
import MySQLdb
import random
import urllib
import urllib2
reload(sys)
sys.setdefaultencoding("utf-8")
def ConnMysql():
    Conn = MySQLdb.connect(host='****',user='root',passwd='root123',db='******',port=3306,charset='utf8')
    cursor =Conn.cursor()
    
    cursor.execute("SELECT member_id FROM base_member_info WHERE  Member_id > 101000")
    MemberidResult =cursor.fetchall()        
    for Member_id in MemberidResult:
    #向表app_deposit_banalce插入数据
        
        InsertAppDepositBanalce ="""insert into app_deposit_balance(MEMBER_ID, AUCTION_ID, DEPOSIT_BALANCE, DEPOSIT_RATE, DEPOSIT_BALANCE_STATE)
                                    VALUES(%s,%s,%s,%s,%s)"""
        InsertAppDepositBanalceValue =(Member_id,'6495','10000000000','10','1')
        cursor.execute(InsertAppDepositBanalce,InsertAppDepositBanalceValue)
        
         Conn.commit()


        
ConnMysql()


执行运行的时候,报下面错误

E:\>python BankInsert.py
Traceback (most recent call last):
  File "BankInsert.py", line 27, in <module>
    ConnMysql()
  File "BankInsert.py", line 21, in ConnMysql
    cursor.execute(InsertAppDepositBanalce,InsertAppDepositBanalceValue)
  File "D:\Program Files\python\lib\site-packages\MySQLdb\cursors.py", line 174,
 in execute
    self.errorhandler(self, exc, value)
  File "D:\Program Files\python\lib\site-packages\MySQLdb\connections.py", line
36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax
; check the manual that corresponds to your MySQL server version for the right s
yntax to use near '),'6495','10000000000','10','1')' at line 2")



<无标签>
举报
Love_Python
发帖于4年前 3回/1K+阅
顶部