简体   繁体   English

mysql编辑器选择查询和python程序选择查询结果的区别

[英]difference in mysql editor select query and python program select query result

I am executing a select query from python program to MySQL 5.2.39 database. 我正在执行从python程序到MySQL 5.2.39数据库的选择查询。 But the result from mysql editor select query and python program select query is slightly different. 但是mysql编辑器选择查询和python程序选择查询的结果略有不同。 Database name is world, table name is wordcount, it has 4 column: id, author, word,count. 数据库名称是世界,表名称是wordcount,它有4列:id,author,word,count。 why those L suffix coming in python result ? 为什么那些L后缀出现在python结果中? can anybody tell what could be the reason ? 有人能说出原因吗? even I have tried to put the whole long select query expression in single line in my python code but still same problem. 即使我试图将整个长选择查询表达式放在我的python代码中的单行中,但仍然存在相同的问题。 I am using Eclipse with Pydev. 我在Pydev中使用Eclipse。 Below is my python code : 以下是我的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

sample result from python : 来自python的示例结果:

('A  GONZ  LEZ', 18L, 19L)
('A  M  MORENO', 8L, 9L)

sample result from MySQL editor : 来自MySQL编辑器的示例结果:

A  GONZ  LEZ|18|19
A  M  MORENO| 8| 9

They're the same values, even if the representation is different. 即使表示形式不同,它们也是相同的值。 When L is after a number in Python < 3, that means the number is a long , which is a specific type of number. L在Python <3中位于数字之后时,表示数字为long ,这是数字的一种特定类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM