您的位置 首页 编程知识

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

快速 html – 500 服务器错误 notfounderror:需要 2 个 pk 如果有人在…

快速 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 的类型为 。接下来返回第一项;第二个参数是默认值。

摘要和其他细节

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

还有

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

以上就是快速 HTML – ** 服务器错误 NotFoundError:需要 k**的详细内容,更多请关注php中文网其它相关文章!

本文来自网络,不代表四平甲倪网络网站制作专家立场,转载请注明出处:http://www.elephantgpt.cn/1494.html

作者: nijia

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

联系我们

联系我们

18844404989

在线咨询: QQ交谈

邮箱: 641522856@qq.com

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部