Python プログラムから MySQL 5.2.39 データベースへの選択クエリを実行しています。ただし、mysql エディターの選択クエリと python プログラムの選択クエリの結果は少し異なります。データベース名は world、テーブル名は wordcount で、id、author、word、count の 4 つの列があります。これらの L サフィックスが Python の結果に含まれるのはなぜですか? 誰が理由を教えてもらえますか?Pythonコードで長い選択クエリ式全体を1行に入れようとしましたが、それでも同じ問題です。私は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 からのサンプル結果:
('A GONZ LEZ', 18L, 19L)
('A M MORENO', 8L, 9L)
MySQL エディターからのサンプル結果:
A GONZ LEZ|18|19
A M MORENO| 8| 9