我正在执行从python程序到MySQL 5.2.39数据库的select查询。但是mysql编辑器select query和python程序select query的结果略有不同。数据库名是world,表名是wordcount,它有4列:id,author,word,count。
为什么python结果中会出现L后缀?有人能说出原因吗?即使我在python代码中也尝试过将整个long select查询表达式放在一行中,但仍然存在相同的问题。我在Pydev中使用Eclipse。下面是我的python代码:import MySQLdb as mdb
import sys
con = mdb.connect('localhost', 'root', '1234', 'world')
con.autocommit(True)
with con:
cur = con.cursor()
cur.execute("select author,count(distinct word),count(distinct id) from \
world.wordcount \
group by author \
having count(distinct word)<> count(distinct id) \
order by author")
rows = cur.fetchall()
for row in rows:
print row
来自python的示例结果:
^{pr2}$
MySQL编辑器的示例结果:
^{3}$