Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created July 31, 2020 17:19
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/8c578df9a8004a28ff0862f7835f5597 to your computer and use it in GitHub Desktop.
Save CodeDrome/8c578df9a8004a28ff0862f7835f5597 to your computer and use it in GitHub Desktop.
pgdml.py Part 4
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