从sqllite提取用户信息3
我正在使用python和sqllite3创建银行GUI。
在代码中的这一点上,用户已登录。我正在尝试显示与用户关联的信息。每个用户名都是唯一的 - 因此,在这里,我试图获取与“ user_name2”相关的名称,而“ user_name2”只是以前用于登录的用户名。它返回光标对象。我该如何简单地将值打印到我的GUI中?
get_name = cur.execute(f"SELECT name FROM all_accounts WHERE username = '{user_name2}'")
Label(user_info, text=f"Name:{get_name}", font="times 13").grid(row=0, sticky=NW, pady=10, padx=30)
I am creating a banking GUI using python and SQLLITE3.
At this point in the code, the user has logged in. I am trying to display the information associated with the user. Every username is unique--so here I am attempting to get the name that is associated with "user_name2" which is just the username that had been previously used to login. It returns a cursor object. How can I get it to simply print the value into my GUI?
get_name = cur.execute(f"SELECT name FROM all_accounts WHERE username = '{user_name2}'")
Label(user_info, text=f"Name:{get_name}", font="times 13").grid(row=0, sticky=NW, pady=10, padx=30)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我的答案
安全警告,
如果您不过滤
user_name2
,坏人将对数据库进行SQL注入攻击。您可以咨询这最简单的方法是使用Plaecholder, python很容易
Here is my answer
Security WARNING
If you do not filter
user_name2
, bad guys will conduct SQL injection attack to your database. You can consult thisThe simplest method is using plaecholder, which is very easy in python