-1

I am receiving this error:

query() argument 1 must be string or read-only buffer, not tuple. 

I am not sure what it is after trying to change my code:

def insert_popularity(Category, filename, cursor):

    txt_file = file(filename, 'r')
    for line in txt_file:
            # Split the line on whitespace
        number, value = line.split()
            # construct the SQL statement
        sql = ("""INSERT INTO popularity (PersonNumber, Category, Value)
                VALUES(%s, %s, %s)""", (number, Category, value))
            # execute the query
        cursor.execute(sql)

connection = MySQLdb.connect(host='localhost', user='root', \
                                 passwd='password', db='dogs')

cursor = connection.cursor()

Category = 'dogs'
insert_popularity(Category, 'dogs.txt', cursor)



connection.commit()

cursor.close()

connection.close()
Björn Pollex
  • 75,346
  • 28
  • 201
  • 283
Alana
  • 19
  • 1
  • 4
  • 1
    -1: Are you the same Ree guy? You should have accepted my answer to the original question (http://stackoverflow.com/questions/6148293/) or asked for help there. – Paulo Scardine May 27 '11 at 07:23

0 Answers0