Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created July 31, 2020 17:28
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/907a0a1e8802ea5e6329322e0eef5aee to your computer and use it in GitHub Desktop.
Save CodeDrome/907a0a1e8802ea5e6329322e0eef5aee to your computer and use it in GitHub Desktop.
pgdml.py Part 7
def reset_serial():
try:
conn = pgconnection.get_connection("codeinpython")
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute("ALTER SEQUENCE photos_photoid_seq RESTART WITH 1")
print("photo table serial reset")
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