我试图使用Python的(3.4)MySQL模块在本地MySQL数据库上查询,代码如下:
class databases():
def externaldatabase(self):
try:
c = mysql.connector.connect(host="127.0.0.1", user="user",
password="password", database="database")
if c.is_connected():
c.autocommit = True
return(c)
except:
return(None)
d = databases().externaldatabase()
c = d.cursor()
r = c.execute('''select * from tbl_wiki''')
print(r)
> Returns: None
Run Code Online (Sandbox Code Playgroud)
据我所知,连接成功,数据库由多行组成,但查询始终返回none类型.
MySQL执行函数返回None的实例是什么?