Re: [pgAdmin4][RM#3289] Can't query SQL_ASCII database.

From: Aditya Toshniwal <aditya(dot)toshniwal(at)enterprisedb(dot)com>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Joao De Almeida Pereira <jdealmeidapereira(at)pivotal(dot)io>, pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: [pgAdmin4][RM#3289] Can't query SQL_ASCII database.
Date: 2018-06-18 13:14:11
Message-ID: CAM9w-_=8k4gBg_kji7KQ7FO=j18tCU5kDzu1YGGF3Xw7XEfK7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hi Hackers,

Attached is the updated patch which includes the fix for Download CSV fail
in SQL_ASCII database, which is RM3250
<https://redmine.postgresql.org/issues/3250>
This should fix RM3289 and RM3250. As they interrelated, sending the
combined patch.
Kindly review.

On Fri, Jun 15, 2018 at 2:33 PM, Aditya Toshniwal <
aditya(dot)toshniwal(at)enterprisedb(dot)com> wrote:

> Hi Dave,
>
> On Fri, Jun 15, 2018 at 2:08 PM, Dave Page <dpage(at)pgadmin(dot)org> wrote:
>
>> Hi
>>
>> On Thu, Jun 14, 2018 at 7:05 AM, Aditya Toshniwal <
>> aditya(dot)toshniwal(at)enterprisedb(dot)com> wrote:
>>
>>> I am sorry I missed the attachment. :(
>>> PFA.
>>>
>>
>> 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,799: INFO werkzeug: 127.0.0.1 - - [15/Jun/2018
>> 09:32:28] "GET /sqleditor/query_tool/download/2732923?query=SELECT%20*%
>> 20FROM%20public.sql_ascii%0AORDER%20BY%20id%20ASC%20&filename=sql_ascii.csv
>> HTTP/1.1" 500 -
>> 2018-06-15 09:32:28,801: ERROR werkzeug: 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.
> conn_encoding = cur.connection.encoding
> column_name = column_name.decode(conn_encoding)​
>
>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
>
> --
> Thanks and Regards,
> Aditya Toshniwal
> Software Engineer | EnterpriseDB Software Solutions | Pune
> "Don't Complain about Heat, Plant a tree"
>

--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB Software Solutions | Pune
"Don't Complain about Heat, Plant a tree"

Attachment Content-Type Size
RM3289_3250.patch application/octet-stream 12.3 KB

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Akshay Joshi 2018-06-18 13:38:01 [pgadmin4][Patch]: RM #3361 Create database dialog does not show template0 and template1 database in Template dropdown
Previous Message Akshay Joshi 2018-06-18 11:18:16 [pgadmin4][Patch]: Feature #3388 Allow to set the connection timeout on the server properties dialog