- 论坛徽章:
- 0
|
- import os
- import MySQLdb
- def onlineinsert(val,database):
- try:
- conn=MySQLdb.connect(host='localhost',user='root',passwd='123456',db=database)
- except:
- pass
-
- cursor=conn.cursor()
- sql='insert ignore into onlinetimerecord(PlayerID,AccountID,ClientType,OnlineTime,OfflineTime,LoginIP,DiamondLogin,DiamondLogoff) values(%s,%s,%s,%s,%s,%s,%s,%s)'
- print sql
- cursor.execute(sql,val)
- if __name__=='__main__':
- val=[(4295188411, 86364, 3, "2011-05-29 23:59:29", "2011-05-30 00:00:22", "115.225.23.218", 0, 0),(4295695241, 3371381, 3, "2011-05-29 22:18:50", "2011-05-30 00:01:11", "183.6.149.50", 0, 0)]
- onlineinsert(val,'jyw-gamerecord-1003')
复制代码 报错信息:
Traceback (most recent call last):
File "F:\out.py", line 17, in <module>
onlineinsert(val,'jyw-gamerecord-1003')
File "F:\out.py", line 13, in onlineinsert
cursor.execute(sql,val)
File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 159, in execute
query = query % db.literal(args)
TypeError: not enough arguments for format string
本人是新手,高人指点!! |
|