python mysql-connector每次都给出None作为结果。

时间:2017-02-16 08:28:47

标签: python-3.x mysql-connector mysql-connector-python

这里有什么问题?任何指针

f=mysql.connector.connect(user='root',password='password',host='10.XX.XX.XX.XX',database='branchQA')
>>> f
<mysql.connector.connection.MySQLConnection object at 0x02CB6A30>
>>> c=f.cursor()
>>> c
<mysql.connector.cursor.MySQLCursor object at 0x02CB6E50>
>>> k=c.execute("show databases")
>>> k
>>> print k
  File "<stdin>", line 1
    print k
          ^
SyntaxError: Missing parentheses in call to 'print'
>>> print(k)
None
>>> print(k)

我执行了它显示的相同查询:

  1. INFORMATION_SCHEMA

  2. mysql

  3. 测试

  4. branchQA

1 个答案:

答案 0 :(得分:0)

执行后的Fetchall或fetchone可以解决问题。

 >>> c.execute
   >>>k = c.fetchall() 
   >>>k