Reputation: 1620
I'm currently using an example to select a variable from MySQL via Python. For this I'm using the MySQLdb import.
It all works great, I'm able to get the value from MySQL but when I print the result, it returns as:
('text',)
Is there a way to get this to just show up as
text
The code I'm working with is:
try:
cursor.execute("""SELECT value FROM settings WHERE name='text'""")
results = cursor.fetchone()
print results
Thank you!!
Upvotes: 0
Views: 155
Reputation: 3452
Python 3 :
print(results[0])
Python 2 :
print results[0]
This will take the first and only element of the tuple, which is 'text'
, and printing a string will just write text
without quotes in the console.
Upvotes: 2