96 if not rows:
97 raise ValueError("refusing to publish zero rows…")
98
101 staging = Identifier(schema, f"{table}__staging")
102 published = Identifier(schema, table)
108 connection = psycopg.connect(dsn, autocommit=False)
111 cursor.execute(SQL("drop table if exists {}").format(staging))
112 cursor.execute(SQL("create table {} ({})").format(staging, definition))
113 cursor.executemany(SQL("insert into {} …"), rows)
123 cursor.execute(SQL("drop table if exists {}").format(published))
124 cursor.execute(SQL("alter table {} rename to {}").format(staging, Identifier(table)))
130 cursor.execute(SQL("comment on table {} is {}")…)
135 connection.commit()