【问题标题】:Python/MySQLdb/cursor.executemany()Python/MySQLdb/cursor.executemany()
【发布时间】:2015-03-12 15:25:20
【问题描述】:

我正在对给定的 MySQL 数据库执行一个非常简单的查询。比方说:

>>> cur = mydb.cursor()
>>> results = cur.executemany("select field from table where field = %s", ('value1', 'value2', 'value3'))
>>> print results
4

到目前为止一切都很好......

>>> rows = cur.fetchall()
>>> print rows
field for value3

所以问题是它只打印value3 的答案,而不是value2value1 的答案

如何获取我正在执行的操作的整个结果。

谢谢!

【问题讨论】:

    标签: python mysql-python


    【解决方案1】:

    改为:

    print rows 
    

    试试这个:

    for r in rows:
        print r
    

    【讨论】:

      猜你喜欢
      • 2021-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-20
      • 2010-11-10
      • 2012-12-04
      • 2011-11-10
      相关资源
      最近更新 更多