Anthony Mendoza
Anthony Mendoza

Reputation: 33

AttributeError: 'tuple' object has no attribute 'encode' python gui

I'm having this error AttributeError: 'tuple' object has no attribute 'encode' and here is the part of my code. can you please help me

cur = conn.cursor()
sql = "SELECT * FROM farm_registration \
       WHERE barangay = %s", (e_barangay);
cur.execute(sql)
results = cur.rowcount

Upvotes: 0

Views: 3009

Answers (1)

johnII
johnII

Reputation: 1433

This statement returns a tuple

sql = "SELECT * FROM farm_registration \
       WHERE barangay = %s", (e_barangay);

which you are expecting string instead, so just changed the above into

sql = "SELECT * FROM farm_registration \
       WHERE barangay = %s" % e_barangay;

Upvotes: 1

Related Questions