Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Does not execute empty SQL queries. pyscopg2 cannot execute empty sql qu... #69

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions mysql2pgsql/lib/postgres_db_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ def query(self, sql, args=(), one=False):
return cur.fetchone() if one else cur

def execute(self, sql, args=(), many=False):
with closing(self.conn.cursor()) as cur:
if many:
cur.executemany(sql, args)
else:
cur.execute(sql, args)
self.conn.commit()
if sql.strip():
with closing(self.conn.cursor()) as cur:
if many:
cur.executemany(sql, args)
else:
cur.execute(sql, args)
self.conn.commit()

def copy_from(self, file_obj, table_name, columns):
with closing(self.conn.cursor()) as cur:
Expand Down