Created
July 31, 2020 17:19
-
-
Save CodeDrome/8c578df9a8004a28ff0862f7835f5597 to your computer and use it in GitHub Desktop.
pgdml.py Part 4
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 delete_photos(): | |
delete_dict = {"photoid": 10} | |
try: | |
conn = pgconnection.get_connection("codeinpython") | |
cursor = conn.cursor() | |
cursor.execute("DELETE FROM photos WHERE photoid = %(photoid)s;", delete_dict) | |
conn.commit() | |
print("Photo deleted") | |
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