基本上,我从表中返回数据:
>mysql> SELECT x,y FROM xandy;
>+------+------+
>| x | y |
>+------+------+
>| 5 | 2 |
>| 4 | 6 |
>| 7 | 6 |
>| 4 | 6 |
>| 8 | 7 |
>| 4 | 6 |
>| 11 | 33 |
>| 33 | 22 |
>+------+------+
>8 rows in set (0.00 sec)
(抱歉格式不佳)
def fetch():
try:
db = MySQLdb.connect("localhost",user="root",passwd="****",db="logger")
cursor=db.cursor()
SQLString = "SELECT x,y FROM xandy;"
cursor.execute(SQLString)
rows=cursor.fetchall()
return rows
db.close()
但是,当我得到返回的值时,我将其全部放在一行中,格式为:
((5.0,2.0),(4.0,6.0),(7.0,6.0),(4.0,6.0),(8.0,7.0),(4.0,6.0),(11.0,33.0),(33.0,22.0), (6.0,4.0))
有没有办法以简单的表格形式显示它,即x和y两列? (p.s我将在此步骤后使用gnuplot)