tuple_from_list.py

  1. def get_some_data():
  2. # Get some data from MySQL - ignore this bit.
  3. cur = MySQLdb.cursor()
  4.  
  5. # Now, loop over each (single-field) result, and build a list.
  6. result = list()
  7. for row in cur.fetchall():
  8. result.append(row[0])
  9.  
  10. # Make a tuple from the list and return.
  11. return tuple(result)
  12.