Python mysql fetchall converting tuple to normal string variable

Thread Starter

zazas321

Joined Nov 29, 2015
668
Hello. I am trying to get the data out of my MYSQL database using python fetchall. I only need to get retrieve 1 row of data and that seems to be working fine except that It returns data in a weird tuple format. Is there any way to convert this data to just a simple strings without any brackets?

My code:
Code:
def restart_devices():
   
    cur = myConnection.cursor()
    query = "SELECT Device FROM pack_to_light"
    cur.execute(query)
    for Device in cur.fetchall() :
       
        print("device=",Device)
Output:
Code:
device= ('device1',)
device= ('device2',)
device= ('device3',)
All I need is 3 seperate strings "device1", "device2" and "device3"

my database:

2020-08-31-072634_1920x1080_scrot.png
 
Last edited:
Top