Skip to content

Commit

Permalink
Merge pull request #128 from dathere/syc_buffer_with_copyexpert
Browse files Browse the repository at this point in the history
sync read buffer with buffer size of copyexpert
  • Loading branch information
jqnatividad authored Jan 23, 2024
2 parents 6e21862 + 842dd99 commit 48395c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions datapusher/dot-env.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ WRITE_ENGINE_URL = 'postgresql://datapusher:YOURPASSWORD@localhost/datastore_def
SQLALCHEMY_DATABASE_URI = 'postgresql://datapusher_jobs:YOURPASSWORD@localhost/datapusher_jobs'

# READ BUFFER SIZE IN BYTES WHEN READING CSV FILE WHEN USING POSTGRES COPY
# default 1mb = 1048576
COPY_READBUFFER_SIZE = 1048576
# default 64k = 65536
COPY_READBUFFER_SIZE = 65536

# =============== DOWNLOAD SETTINGS ==============
# 25mb, this is ignored if either PREVIEW_ROWS > 0
Expand Down
2 changes: 1 addition & 1 deletion datapusher/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None):
# specify a 1MB buffer size for COPY read from disk
with open(tmp, "rb", copy_readbuffer_size) as f:
try:
cur.copy_expert(copy_sql, f)
cur.copy_expert(copy_sql, f, size=copy_readbuffer_size)
except psycopg2.Error as e:
raise util.JobError("Postgres COPY failed: {}".format(e))
else:
Expand Down

0 comments on commit 48395c9

Please sign in to comment.