I am grabbing data out of MS SQL via python via:
cursor.execute('SELECT IP FROM Nodes WHERE NodeGroup=%s', 'group1')
row = cursor.fetchall()
return row
I am receiving this as the return:
[('10.10.10.10',), ('10.10.10.20',), ('10.10.10.30',), ('10.10.10.40',)]
I need it to be in the format of:
['10.10.10.10', '10.10.10.20', '10.10.10.30', '10.10.10.40']
I'm assuming this is a tuple of tuples? How can I get the output I'm looking for from the .fetchall()?
You could turn your tuples to a list
row = [ r[0] for r in cursor.fetchall() ]