It looks like the encoding names are getting munged somewhere. I see you've accounted for that to some degree in connection.py (you have both SQL_ASCII/MULE_INTERNAL and SQLASCII/MULEINTERNAL), however it doesn't seem to be enough as I'm getting the following error when trying to download CSV from the query tool. Can we ensure that conn.encoding contains an un-munged value at all times, or is that coming from psycopg2?
That is done by pyscopg2 and conn.encoding is a psycopg2 connection property.
2018-06-15 09:32:28,801: ERRORwerkzeug:Error on request:
Traceback (most recent call last):
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
execute(self.server.app)
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/serving.py", line 260, in execute
for data in application_iter:
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/wsgi.py", line 870, in __next__
return self._next()
File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/werkzeug/wrappers.py", line 82, in _iter_encoded
for item in iterable:
File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/driver/psycopg2/connection.py", line 752, in gen
column_name = column_name.decode(conn_encoding)
LookupError: unknown encoding: SQLASCII
This is because there is code bug here. Below is code used to decode a column name. Connection encoding and python encoding are two different things. Python does not know what SQLASCII is. This will work with UTF-8 because python has decoder with same name. I tried to download CSV with the original code without changes and it fails there too. I will fix this and will send the updated patch. I should have checked this.