Skip to content

Instantly share code, notes, and snippets.

@daniel-schroeder-dev
Created April 6, 2023 13:39
Show Gist options
  • Save daniel-schroeder-dev/f0b7ea67a91cd676ac500056d495d3b3 to your computer and use it in GitHub Desktop.
Save daniel-schroeder-dev/f0b7ea67a91cd676ac500056d495d3b3 to your computer and use it in GitHub Desktop.
How to populate request dictionary with usernames
# 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