python - 在 mysql 函数中返回一个布尔值并在 python 中使用它
问题描述
所以我需要的是在 MySQL 的函数中返回一个布尔值,并在 Python 中使用它作为 Python 函数中的条件。我有这个
class A:
def login():
username: input("Username: ")
password: input("Password: ")
if B.user_exists(username, password):
# do something
和
class B:
def user_exists(cls, username, password):
try:
db = cls.conection()
cursor = db.cursor()
cursor.execute("SELECT UserExists(%s, %s)", (username, password))
# here it should be something to return if it's true or false
Error:
print("Error", Error)
注意:MySQL 的功能工作正常,我在 Datagrip 上对其进行了测试,所以这不是问题
解决方案
推荐阅读
- php - 如何在 PHP 中获取 Chargebee 关联数组响应
- javascript - Elasticsearch 在 Jasmine 测试中没有按时索引
- r - R中的非线性回归:奇异梯度
- javascript - 如何将坐标传递给 Leaflet 中的 LatLng 函数
- bash - Bash:迭代变量列表
- python - NumPy 中的单位矩阵堆叠
- java - Jenkins 在找不到“.part”文件时构建失败
- python - 根据匹配列将信息从一个数据帧合并到另一个数据帧
- c# - Task.Factory.StartNew 和 Parallel.Invoke 的线程可以在不同的处理器或内核上运行
- arrays - bash 构建查找的选项列表