Search code examples
databasepython-3.xmysql-connector-python

A separator different from comma when applying cursor.fetchall()


I am using mysql.connector in Python to get queries from a Mysql database. However, the data are separated by comma. Can I change the separetor when using the cursor.fetchall()?


Solution

  • I'm pretty sure that fetchall() returns a list of the rows found, so you can then format the rows however you want to.

    For example, print '\n'.join(cursor.fetchall()) would put a newline between each row.