From b02459124188db3ff3dda481b890d3374f99cdef Mon Sep 17 00:00:00 2001 From: ganesh_krishnan Date: Mon, 4 Mar 2019 17:30:56 -0800 Subject: [PATCH] Enable quoting for Snowflake --- lore/io/connection.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lore/io/connection.py b/lore/io/connection.py index 1f9f811..126c675 100644 --- a/lore/io/connection.py +++ b/lore/io/connection.py @@ -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 }