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>

<p>you can execute the same code just by adding limits to the Sql Query.</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')
limitvalue=1000
for offsetvalue in range(0 , maximum_rows_you_want,1000):
    c.execute("SELECT * FROM administrations limit "+ limitvalue + " offset " + offsetvalue +";")
    for row in c:
        print row
</code></pre>

python mysql sql python-2.7 web