0

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

1 Answer 1

1

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]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.