Display select Mysql query in python with output nice and readable
<p>I need python script for display sql query with nice output and readable this not readable for heavy tables...</p>

<pre><code>cnx = mysql.connector.connect(user='root', password='*****',
                              host='127.0.0.1',
                              database='dietetique')
c = cnx.cursor()
sys.stdout = open('mysql_data.log', 'w')
c.execute("SELECT * FROM administrations;")

for row in c:
    print row
</code></pre>

<pre><code>import pypyodbc
ID=2
ConnectionDtl='Driver={SQL Server};Server=WIN7-297;Database=AdventureWorks2014;trusted_connection=yes'
connection = pypyodbc.connect(ConnectionDtl)

print("Retrieve row based on [FirstName]='Mani'")
cursor = connection.cursor()
SQLCommand = ("SELECT [FirstName],[LastName] "
               "FROM Person.SampleData "
               "WHERE FirstName =?")
Values = ['Mani']
print(SQLCommand)
cursor.execute(SQLCommand,Values)
i=1
for x in cursor :
  row = cursor.fetchone()
  print str(i) + ". FirstName: " + row[0] + " LastName: " + row[1]
  i=i+1

connection.close()
</code></pre>

python mysql sql python-2.7 web