Replacing psycopg2.copy_expert with psycopg3.copy

This commit is contained in:
John Westcott IV
2023-04-27 08:03:27 -04:00
committed by John Westcott IV
parent e47d30974c
commit a665d96026
8 changed files with 114 additions and 84 deletions

View File

@@ -399,7 +399,10 @@ def _copy_table(table, query, path):
file_path = os.path.join(path, table + '_table.csv')
file = FileSplitter(filespec=file_path)
with connection.cursor() as cursor:
cursor.copy_expert(query, file)
with cursor.copy(query) as copy:
while data := copy.read():
byte_data = bytes(data)
file.write(byte_data.decode())
return file.file_list()