I have a trouble with my program in my raspberry pi. This is my source code
import MySQLdb
import csv
db=MySQLdb.connect(user='root',passwd='toor',
host='127.0.0.1',db='data')
cursor=db.cursor()
csv_data=csv.reader(file('datasensor.txt'))
for row in csv_data:
sql = "insert into `kelembapan` (`id`,`Tanggal`,`Tipe_sensor`,`Value`,`Ket`) values(%s,%s,%s,%s,%s);"
cursor.execute(sql,row)
db.commit()
cursor.close()
print "The Data has been inputted"
and this is for txt file
1, 2017-10-10, sensor1,40,Kurang lembap
2, 2017-10-10, sensor2,60,Lembap
That program can run in my ubuntu but not in my raspberry. when run in raspberry there is error
Traceback (most recent call last):
File "server.py", line 9, in <module>
cursor.execute(sql,row)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py",line 159, in execute
query = query% db.literal(args)
TypeError: not enough arguments for format strings
Thnks before :)