I am trying to query a MySQL table to get a specific user type depending on their email
import pymysql
conn= pymysql.connect(host='<ip>',user='<user>',password=<pass>',db='<db>')
a = conn.cursor()
a.execute("SELECT `type` FROM `users` WHERE `email` LIKE '<email>';")
data = a.fetchone()
print(data)
The output is ('user',)
, how can I get the output to be just user
It returned a tuple. So check if it has correct number of elements (1) and extract element desired:
if len(data) == 1:
print data[0]