Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hg73S-0000ZF-OT for pgadmin-hackers@arkaria.postgresql.org; Wed, 26 Jun 2019 12:29:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hg73R-0005zW-KB for pgadmin-hackers@arkaria.postgresql.org; Wed, 26 Jun 2019 12:29:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hg73R-0005zO-5s for pgadmin-hackers@lists.postgresql.org; Wed, 26 Jun 2019 12:29:37 +0000 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hg73O-00017U-IO for pgadmin-hackers@postgresql.org; Wed, 26 Jun 2019 12:29:36 +0000 Received: by mail-qt1-x835.google.com with SMTP id m29so2129692qtu.1 for ; Wed, 26 Jun 2019 05:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=qjOz2Nfxjr+RfwkAGi1gw/PstvLqF1e5yL8DmD4M+ac=; b=vCY2qzRd4suhACTOgmfg+94QobJrl7+J8ZRKk/I3D2yPrbxfmmtZvN3UeHxwL3+s0p 3P2ZjCgpcDNL0u2Jy6mQhZALvaT2xl+hxXN9wmIooHD5qnW3SpuGaREORfwEN/uSCFRI WzE1jU5uv4elq1eel+//5ifd2rRCHw4O5cshwqRJ1HT6YuzuZ4wQHbt4J66Z3NsGJEnQ XDcKo0wu6htRKVOtG4Q+UdGR8UQ1DDniWx75W6xaF0YJuzJc5UUAn+WaHTF34n+umGs4 oSGqe4rqK0Svg2glQyXk8+xlTn0OolyFs3TwhbroaAWS1n6s4rZcUpfn1wIJ8LYcL6IG J2xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=qjOz2Nfxjr+RfwkAGi1gw/PstvLqF1e5yL8DmD4M+ac=; b=hsSCNljqELFtAV+QIDvhANviGb3qxz5OFTknQggHht/4S9pIGWcNU7ECm4BeKZ9yxs 6G+6hPTszEibx8A9qngq/iYGHKNt9wWKcGBWpmBch+hHELiJwnAZZvDQ0W0bZ4Ywu1fL LKVvvhuSb7dythJtZdxklVOvrFsdR6nkvYLpeo8T9o3ZknsMr1MVEU0yq+jW1hc0ijq7 UjaW+djL11T4M7b55c4t/wPIfuuHZXWv4/WAxmJ7uQfSFYhgOy6EDhR4PiypGT8/Nm+6 CbzlQyJs2/oYuTZVvb2b2HMS6EjlyyViwHLN6lN/Kirf6Q17sO1VHagH9LKDkFn2eZiG MHKw== X-Gm-Message-State: APjAAAWFbEj10GzEooyTp9Ffp0dmTPEVjeX/3jomoPzCOzXoHvLRGru4 TvzxxprV+CyNSenAgAinS4ZnO1fdPf4M4wU8UuA= X-Google-Smtp-Source: APXvYqzz172SiG1q8Yp+16IhHS7Go45fvuL1pGC0NAEPDy1Edr3ww8DHU29r04PS39K2cpJws5ipnNeYcRMf0ofvSFQ= X-Received: by 2002:ac8:2b51:: with SMTP id 17mr3472330qtv.206.1561552173410; Wed, 26 Jun 2019 05:29:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yosry Muhammad Date: Wed, 26 Jun 2019 14:29:21 +0200 Message-ID: Subject: Re: [GSoC][Patch] Automatic Mode Detection V1 To: Aditya Toshniwal , pgadmin-hackers@postgresql.org, Dave Page Content-Type: multipart/alternative; boundary="000000000000982eee058c3932be" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000982eee058c3932be Content-Type: text/plain; charset="UTF-8" On Wed, Jun 26, 2019 at 11:46 AM Aditya Toshniwal < aditya.toshniwal@enterprisedb.com> wrote: > Hi, > > On Wed, Jun 26, 2019 at 10:35 AM Aditya Toshniwal < > aditya.toshniwal@enterprisedb.com> wrote: > >> >> My problem is not where to store the mogrified query, I can just replace >>> the sql sent with the response to saving the data with the mogrified one. >>> In order to produce the mogrified query in the first place I need a >>> psycopg2.cursor object, but I only have access to a Connection object (the >>> wrapper, not the actual psycopg2.connection object). Should I modify that >>> wrapper Connection class to add a mogirfy function? or just get a cursor >>> using the psycopg2.connection object like this: conn.conn.cursor() - which >>> doesn't seem right. Thoughts? >>> >> That would be the way. But I think >> web/pgadmin/utils/driver/psycopg2/cursor.py will be corrrect place to add >> the mogrify function. Please note, psycopg2 does not support (,),% in >> the parameter names. So if the column names has any of these characters, >> mogrify might fail. Although it is handled with pgadmin_alias (line 493 >> - web/pgadmin/tools/sqleditor/__init__.py), please test this case as well. >> > You can also get the last executed SQL in psycopg2 - > http://initd.org/psycopg/docs/cursor.html#cursor.query. May be this can > be used. > The cursor wrapper class (DictCursor) is exclusively used by the connection wrapper class (at web/pgadmin/utils/driver/psycopg2/connection.py) as a cursor factory. I think the mogrify function will need to be implemented in both classes, as the Connection class is the one that is used throughout the code - no code uses cursors directly. What do you think? The use of cursor.query will not be possible as this is a property of the cursor, not the connection. I will need to call cursor.query on the exact cursor that was used to execute the query, which is not accessible in this case. Thanks a lot for your help ! >>> Also, could you please help me with the selenium TimeoutException in the >>> feature tests? 3 tests are failing because of that exception and I am not >>> sure what is it related to. I am attaching the feature test log file in >>> this email if you would like to take a look on it. >>> >> Can you check on latest chrome and chromdriver. You can check the >> chromedriver version as below. Your venv should have the chromedriver >> binary. >> >> (pypg37) laptop207:pgadmin4 adityatoshniwal$ chromedriver --version >> ChromeDriver 75.0.3770.8 >> (681f24ea911fe754973dda2fdc6d2a2e159dd300-refs/branch-heads/3770@{#40}) >> >>> >>> >>> The version I have is actually 75.0.3770.90. Could the more recent version be causing the problem ? Thanks and regards. -- *Yosry Muhammad Yosry* Computer Engineering student, The Faculty of Engineering, Cairo University (2021). Class representative of CMP 2021. https://www.linkedin.com/in/yosrym93/ --000000000000982eee058c3932be Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Jun 26, 2019 at 11:46 AM Adit= ya Toshniwal <adity= a.toshniwal@enterprisedb.com> wrote:
Hi,

On Wed, Jun 26, 2019 at 10:35 AM = Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
=

My problem is not where to s= tore the mogrified query, I can just replace the sql sent with the response= to saving the data with the mogrified one. In order to produce the mogrifi= ed query in the first place I need a psycopg2.cursor object, but I only hav= e access to a Connection object (the wrapper, not the actual psycopg2.conne= ction object). Should I modify that wrapper Connection class to add a mogir= fy function? or just get a cursor using the psycopg2.connection object like= this: conn.conn.cursor() - which doesn't seem right. Thoughts?
That would be the way. But I think web/pgadmin/util= s/driver/psycopg2/cursor.py will be corrrect place to add the mogrify function. Please note, psycopg2 does not support (,),% in the parameter na= mes. So if the column names has any of these characters, mogrify might fail= . Although it is handled with pgadmin_alias (line 493 - web/pgadmin/tools/sqleditor/__init__.py), please test this c= ase as well.
You can also ge= t the last executed SQL in psycopg2 -=C2=A0http://initd.or= g/psycopg/docs/cursor.html#cursor.query. May be this can be used.

The cursor wrapper class (D= ictCursor) is exclusively used by the connection wrapper class (at web/pgad= min/utils/driver/psycopg2/connection.py) as a cursor factory. I think the m= ogrify function will need to be implemented in both classes, as the Connect= ion class is the one that is used throughout the code - no code uses cursor= s directly. What do you think?
The use of cursor.query will not b= e possible as this is a property of the cursor, not the connection. I will = need to call cursor.query on the exact cursor that was used to execute the = query, which is not accessible in this case.

Thank= s a lot for your help !


Also, could you please he= lp me with the selenium TimeoutException in the feature tests? 3 tests are = failing because of that exception and I am not sure what is it related to. = I am attaching the feature test log file in this email if you would like to= take a look on it.
Can you check on latest = chrome and chromdriver. You can check the chromedriver version as below. Yo= ur venv should have the chromedriver binary.

(pypg37) laptop207:pgadmin4 adityatoshniwal$ chromedriver=C2=A0 --version

C= hromeDriver 75.0.3770.8 (681f24ea911fe754973dda2fdc6d2a2e159dd300-refs/bran= ch-heads/3770@{#40})=C2=A0



The version I ha= ve is actually 75.0.3770.90. Could the more recent version be causing the p= roblem ?

Thanks and regards.
<= br clear=3D"all">
--
Yosry Muhammad Yosry<= /i>

Computer Engineering student,
The Faculty of Engineering,
Cairo University (2021).
Class repres= entative of CMP 2021.
--000000000000982eee058c3932be--