CartoDB / carto-python

CARTO Python client
https://carto.com
BSD 3-Clause "New" or "Revised" License
154 stars 62 forks source link

Invalid queries when using carto-etl #63

Closed alrocar closed 7 years ago

alrocar commented 7 years ago

The carto-etl script prepares insert sql queries that when going through the SQLClient produce this error in the sql-api:

WARNING:carto-etl:Chunk #4: Retrying ([u'syntax error at or near "+"'])

Seems that the query is encoded in this way:

insert+into+INF_SIPS_CARTO+%28the_geom%2Cc...
alrocar commented 7 years ago

Found the issue... it happens when sending a query with accents.

Since we are not guessing queries encoding, I'm going to leave this out of the SDK implementation.

One way of solving it is by properly encoding the query before sending it to the SQLClient.

sql.send(query.decode('iso-8859-1').encode('utf-8'))