登录
首页 >  文章 >  python教程

快速 HTML - ** 服务器错误 NotFoundError:需要 k**

来源:dev.to

时间:2024-09-09 11:19:03 426浏览 收藏

今天golang学习网给大家带来了《快速 HTML - ** 服务器错误 NotFoundError:需要 k**》,其中涉及到的知识点包括等等,无论你是小白还是老手,都适合看一看哦~有好的建议也欢迎大家在评论留言,若是看完有所收获,也希望大家能多多点赞支持呀!一起加油学习~

快速 HTML - ** 服务器错误 NotFoundError:需要 k**

快速 html - 500 服务器错误 notfounderror:需要 2 个 pk

如果有人在使用快速 html 时遇到此问题,他们试图从具有多个主键的表中获取行并获得需要 2 pk 或需要两个主键的一些变化

问题

500 服务器错误 notfounderror:需要 2 个 pk

我的架构定义为:

users.create(dict(username=str, pwd=str, role=str), pk='username',transform=true)
imgs.create(id=int, username=str, mime=str, b64=str, created_at=str, score=int, pk=('id', 'username'),transform=true)
...
imgs = imgs() # this is where i'm trying to return the list of images.

回答

明确地说:问题是该表需要两个主键。

你可以这样做:imgs[['1', "admin"] 根据迷你数据 api 规范。但是,这会返回一张图像。

假设您想获取特定用户的所有图像:

users.username = "admin"
imgs = imgs.rows_where("username = ?", [users.username]), none))

“给我用户名是‘admin’的所有行(如果没有找到,就给我无)”

或者如何获取与特定 id 匹配的第一张图像:

id = 0
img = next(imgs.rows_where("id = ?", [id]), None)

“给我 id 为 0 的第一行,(如果没有找到,给我 none)”


其中 imgs 的类型为 <class 'sqlite_minutils.db.table'>。接下来返回第一项;第二个参数是默认值。

摘要和其他细节

可能有一种更惯用的快速 html 方式来做到这一点。不过我确实喜欢这些表达方式读起来很好。

还有

值得注意的是,<class 'sqlite_minutils.db.table'> 的类型是 <class 'sqlite_utils.db.table'> 类型的子类。所以我们可以在这里查看文档 https://sqlite-utils.datasette.io/en/stable/python-api.html#listing-rows

理论要掌握,实操不能落!以上关于《快速 HTML - ** 服务器错误 NotFoundError:需要 k**》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!

声明:本文转载于:dev.to 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>