Created
July 31, 2020 17:28
-
-
Save CodeDrome/907a0a1e8802ea5e6329322e0eef5aee to your computer and use it in GitHub Desktop.
pgdml.py Part 7
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 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