尝试开发一些代码,以便在按下按钮时我可以返回 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