Apr-21-2020, 07:23 PM
I'm selecting data from a table and returning all records. However, the records are being returned with a blank space separator instead of a comma. Any idea how to return rows like the following:
Thanks!
Output:1,sales,marketing,04212020
Instead of:Output:1 sales marketing 04212020
Here's the function:1 2 3 4 5 6 7 8 9 10 11 12 13 |
def select_from_database(conn, tablename): cursor = conn.cursor() print ( "Connected to: %s" % database) cursor.execute( "SELECT * FROM %s " % tablename) rows = cursor.fetchall() print ( "Total records: %s" % len (rows)) for i in rows: print ( * i) #print("%s %s" % (row[0], row[1])) cursor.close() |