Never concatenate strings to build a query.

with cursor.copy("COPY weather FROM STDIN (FORMAT BINARY)") as copy: for row in large_dataset: copy.write_row(row)