1

As per the title say: Is there a way to print standard/native MySQL output on the screen? I'm talking about, e.g. something like this:

san@pcjq:~$ mysql -uroot -p mysql -t -e "SELECT Host,User FROM user;"
Enter password: 
+-----------+------------------+
| Host      | User             |
+-----------+------------------+
| %         | slvUser          |
| 127.0.0.1 | root             |
| localhost | debian-sys-maint |
| localhost | root             |
| localhost | sant00           |
+-----------+------------------+

I'm using MySQLdb and printing fetchall() doesn't do that at all.

In [11]: cur.execute("SELECT Host,User FROM user")
Out[11]: 5L

In [12]: print cur.fetchall()
(('%', 'slvUser'), ('127.0.0.1', 'root'), ('localhost', 'debian-sys-maint'), ('localhost', 'root'), ('localhost', 'sant00'))

Anyone know a how to do that or if it's possible at all? Cheers!!

MacUsers
  • 2,091
  • 3
  • 35
  • 56
  • possible duplicate of [Print results in MySQL format with Python](http://stackoverflow.com/questions/10865483/print-results-in-mysql-format-with-python) – A. Rodas Apr 22 '13 at 20:27
  • @A. Rodas: yes, it appears to be similar but the answer requires `prettytable` third-party library, which I don't really want. It didn't pop up in my search though prior to me posting. – MacUsers Apr 22 '13 at 21:16

0 Answers0