Python Peewee类TypeError在尝试选择/wh时

2024-09-28 17:00:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用peewee中的select()和where()函数在Postgresql数据库中获取散列密码,但是得到了类TypeError。从json接收电子邮件,然后解码。你知道吗

功能:

person_decode = person_string.decode("UTF-8")
person_json = json.loads(person_decode)
personemail = person_json["email"]
hashed = personmodel.Person.select(personmodel.Person.password).where(personmodel.Person.email == personemail)

你知道吗人物模型人物地址:

class Person(basemodel.BaseExtModel):
    email = TextField(primary_key=True)
    password = TextField()

当我运行print(散列)时,它会被打印出来:

<class 'lib.models.personmodel.Person'> SELECT "t1"."password" FROM "person" AS t1 WHERE ("t1"."email" = %s) ['correctemail@email.com']

当我在Postico中运行查询时,它不会通过%s,但当我删除%s并放入电子邮件时,它会成功运行。在select和where函数中我的参数是否有错误?你知道吗

提前谢谢。你知道吗


Tags: 函数jsonemailpasswordwhereselectclassperson