Created
July 31, 2020 17:17
-
-
Save CodeDrome/7ff17dbf3a26e20fc5fe42ab0e91a01a to your computer and use it in GitHub Desktop.
pgdml.py Part 3
This file contains 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
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