In case anybody runs into this issue using fast HTML where they are trying to get rows from a table with multiple primary keys And get some variation of need 2 PK or need two primary keys
500 Server Error NotFoundError: Need 2 pk
My schema are defined as:
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.
To be explicit: the problem is that the table is expecting two primary keys.
And you can do so like this: imgs[['1', "admin"] as per the mini data API Spec. But, this returns one image.
Say you wanna get all of the images by a specific user:
users.username = "admin" imgs = imgs.rows_where("username = ?", [users.username]), None))
"Give me all the rows where the username is 'admin' (And if not found give me None)"
Or how about getting the first image that matches a specific ID:
id = 0 img = next(imgs.rows_where("id = ?", [id]), None)
"Give me the first row where the id is 0, (And if not found give me None)"
Where imgs is of type
There may be a more idiomatic fast HTML way to do this. However I do like how the expressions read nicely.
And
It's worth noting that the type of
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3