尝试开发一些代码,以便在按下按钮时,我可以返回information_Schema的内容,并允许自己从生成的列表中选择一个数据库,创建该按钮并请求登录并不是一个问题,也可以工作,但是返回结果是失败的,我迄今创建的代码如下:
def mysqlConnect():
import pymysql
import subprocess
sqlUsr = MysqlUsr.get()
sqlpwd = Mysqlpwd.get()
conn = pymysql.connect(host='192.168.0.27', user= sqlUsr, passwd=sqlpwd, db='information_schema')
cursor = conn.cursor()
conn.query("SELECT SCHEMA_NAME FROM SCHEMATA")
data = cursor.fetchall()
print (data)data = conn.fetchall()行似乎给出了一个与方括号()有关的错误,因为在代码中必须首先处理这个问题,但我不明白为什么,我看到的所有示例都有这种语法?我想我需要schema_name中的行进入元组,这样我就可以将这些信息用作“下拉”选择框?有没有人做过类似的事?在返回行之前,我无法创建下拉列表,目前,当fetchall()命令失败时,我只能返回行数。
Exception in Tkinter callback Traceback (most recent call last):
File "C:\Python33\lib\tkinter_init_.py", line 1475, in
call return self.func(*args)
File "S:\python\jon\wrt_toolkit_v5\wrt_toolkit_v6.py", line 97, in
mysqlConnect data = cursor.fetchall()
File "C:\Python33\lib\site-packages\pymysql3-0.4-py3.3.egg\pymysql\cursors.py", line 194,
in fetchall self._check_executed()
File "C:\Python33\lib\site-packages\pymysql3-0.4-py3.3.egg\pymysql\cursors.py", line 64,
in _check_executed self.errorhandler(self, ProgrammingError, "execute() first")
File "C:\Python33\lib\site-packages\pymysql3-0.4-py3.3.egg\pymysql\connections.py", line 184,
in defaulterrorhandler raise errorclass(errorvalue)
pymysql.err.ProgrammingError: execute() first发布于 2014-01-29 13:33:31
在调用cursor.execute(query, args=None)之前,需要调用fetch_all
https://stackoverflow.com/questions/21430396
复制相似问题