Skip to content

Instantly share code, notes, and snippets.

@alex-richman-onesignal
Created January 3, 2023 12:49
Show Gist options
  • Save alex-richman-onesignal/d1e51f2d4e0ae9da80f00457655b2eb8 to your computer and use it in GitHub Desktop.
Save alex-richman-onesignal/d1e51f2d4e0ae9da80f00457655b2eb8 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import sys
import psycopg2
conn = psycopg2.connect(sys.argv[1])
conn.set_session(autocommit=True)
cursor = conn.cursor()
cursor.execute("SELECT pg_drop_replication_slot(slot_name) FROM pg_replication_slots WHERE slot_name LIKE 'test_%';")
for index in range(0, 40):
print(index)
cursor.execute("CHECKPOINT;")
cursor.execute(f"SELECT pg_create_logical_replication_slot('test_{index}', 'pgoutput', false);")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment