Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created July 31, 2020 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeDrome/7ff17dbf3a26e20fc5fe42ab0e91a01a to your computer and use it in GitHub Desktop.
Save CodeDrome/7ff17dbf3a26e20fc5fe42ab0e91a01a to your computer and use it in GitHub Desktop.
pgdml.py Part 3
def update_photos():
update_dict = {"description": "Edinburgh Photo 2", "photoid": 10}
try:
conn = pgconnection.get_connection("codeinpython")
cursor = conn.cursor()
cursor.execute("UPDATE photos SET description = %(description)s WHERE photoid = %(photoid)s;", update_dict)
conn.commit()
print("Photo updated")
cursor.close()
conn.close()
except psycopg2.Error as e:
print(type(e))
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment