Trying to use this syntax:
import MySQLdb as mdb
con = mdb.connect(host = 'host', user = 'user', passwd = 'pwd', db = 'db');
cur = con.cursor()
cur.execute('select distinct name from names');
rows = cur.fetchall()
print(rows)
(('1',), ('2',), ('3',), ('4',), ('5',))
I need to get this output to be in the format of a string so that I can include it as a variable in another query I'll be running in the same script.
'1','2','3','4','5'
I'm running this from command line and have tried a few things:
>>> for row in rows:
... print "%s," % row
...
but unfortunately doesn't give me what I need.