Skip to content
Open
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
5 changes: 3 additions & 2 deletions lore/io/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ def insert(self, table, dataframe, batch_size=10 ** 5):
try:
tmp = tempfile.NamedTemporaryFile(delete=False, suffix='.csv.gz')
tmp.close()
batch.to_csv(tmp.name, index=False, header=False, sep='|', na_rep='\\N', quoting=csv.QUOTE_NONE, compression='gzip')
batch.to_csv(tmp.name, index=False, header=False, sep='|', na_rep='\\N',
quotechar='"', quoting=csv.QUOTE_ALL, compression='gzip')
self._connection.connection.cursor().execute('PUT file://%(path)s @~/staged;' % {'path': tmp.name})
self._connection.connection.cursor().execute(
'COPY INTO %(table)s '
'FROM @~/staged '
'FILE_FORMAT = (TYPE = CSV FIELD_DELIMITER = \'|\' SKIP_HEADER = 0 COMPRESSION = GZIP) '
'FILE_FORMAT = (TYPE = CSV FIELD_DELIMITER = \'|\' SKIP_HEADER = 0 COMPRESSION = GZIP FIELD_OPTIONALLY_ENCLOSED_BY = \'"\') '
'PURGE = TRUE' % {
'table': table
}
Expand Down