Created
April 6, 2023 13:39
-
-
Save daniel-schroeder-dev/f0b7ea67a91cd676ac500056d495d3b3 to your computer and use it in GitHub Desktop.
How to populate request dictionary with usernames
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loop through all requests | |
for request in requests: | |
# Query the DB to get the username of the receiver in this request | |
query = """ | |
SELECT username FROM users WHERE user_id = ?; | |
""" | |
result = sql.execute(query, [request["receiver"]]).fetchone() | |
# Add the username to the request dictionary | |
request["username"] = result["username"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment