Reputation: 33
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
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