简体   繁体   English

Python SQL fetchall() 不返回任何内容

[英]Python SQL fetchall() returns nothing

I am trying to fetch data from my table with this command:我正在尝试使用以下命令从我的表中获取数据:

SELECT userPassword FROM Coins.UserInfo WHERE username = 'Hello';

I have run this in the SQL runner on the database website, and it works fine.我已经在数据库网站上的 SQL 运行程序中运行了它,它运行良好。 However, when I run it through python:但是,当我通过 python 运行它时:

cursor.execute("SELECT userPassword FROM Coins.UserInfo WHERE username = 'Hello';")
print(cursor.fetchall())

It returns an empty list.它返回一个空列表。

Does anyone know why this is happening?有谁知道为什么会这样?

That's the expected behavior if there is no user named "Hello".如果没有名为“Hello”的用户,这是预期的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM