Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdYQx-0007J9-MJ for psycopg@arkaria.postgresql.org; Tue, 26 May 2020 12:11:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jdYQw-0004Q6-Kl for psycopg@arkaria.postgresql.org; Tue, 26 May 2020 12:11:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdYQw-0004Pz-DU for psycopg@lists.postgresql.org; Tue, 26 May 2020 12:11:50 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jdYQu-0002sT-9y for psycopg@postgresql.org; Tue, 26 May 2020 12:11:49 +0000 Received: by mail-lj1-x22a.google.com with SMTP id e4so1701210ljn.4 for ; Tue, 26 May 2020 05:11:47 -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 :cc; bh=KqCWeqvPjnA2IKYDjTn4cSfUUJwxL5XlIwrcx3UxZc0=; b=WzbV8Wclct2Ac8izlhOP6vPWMfRx0rK+Hbp8aDw2rYBv6WvCekJeBBdPhQEMBkS+PQ tR7F0BPh/KCMf0LBPZfuUP6uRITOiejnJU27NZRxc29DHr/zdJ3qyM576lFqMemcXmlS rQlMdP7R2Axk/XSGbwlZQqAfTXUSBsRkwbIEa3E4v5tCTFvf15JT+OceoLENdBL3XRGG vFg1Qxhvk1aqsnSzdThZftJ9n5bdiEPz4smH4yaVRoIzP0v0C5PgQCZ4qrUllpLOTp5w 8skhiVcrPx5tgITNw4oa2ni0GQFUtiyNKjPmLCNOBhpGXksK/p1Y2wz1Rvdx9u5NdNwA NJnQ== 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:cc; bh=KqCWeqvPjnA2IKYDjTn4cSfUUJwxL5XlIwrcx3UxZc0=; b=o4cQPHfM2MAxiK5RQZNgjUMWLnZmGhoQdSj/ZU1ojiRx0xV5NvnQZYaydLoyKAcZ6N 5qvvydhZr5sG/qfQifzIXElEVHvqs3fykhyoX9eC+yN88gN80C5xHmPGfVXUqq+9gEXi Qm29gnRjzg3TDrNjdxgH8MPnKaUcrMLRMZNAmsYuB0UeW2eCqaRlJk64U3x2v7mgsDhL SiYD5p7Gghg839GphxZCAWkceQjlzayDSDj0ACgN+HeEIaKw3YntFxGJ8WVLoCPbfbSZ kQBHYySHibWq9HOB1YMr1MSv7HuMWeShl8IvTidBDP/HpbjZRBuJvNfUP+flq3UqsovZ lXOA== X-Gm-Message-State: AOAM531HY0zTqO8VxNC4iVvZK1u2EETd6RqjIOtanuA+BNJfLenqakvJ STrJFk7bd5pLZ+R/me+DxGLtb4zuUiJrI/lpM8cxH76yByA= X-Google-Smtp-Source: ABdhPJwpzR3Rje24XuQaWY2zrEEwKBLDUs1ag69ID+aVmzLl0E20Eszz4VfODStsjW0FMb6JFJ9SoaosEKtj1eQ7iNI= X-Received: by 2002:a2e:87da:: with SMTP id v26mr470686ljj.14.1590495106403; Tue, 26 May 2020 05:11:46 -0700 (PDT) MIME-Version: 1.0 References: <92a25cd6-5b50-3074-0da6-7394db9e0f0a@chagford.com> In-Reply-To: <92a25cd6-5b50-3074-0da6-7394db9e0f0a@chagford.com> From: Daniele Varrazzo Date: Wed, 27 May 2020 00:11:34 +1200 Message-ID: Subject: Re: Minor issue To: Frank Millman Cc: psycopg@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk No, we don't want to add any intelligence in trying to figure out what is into a query. If you are comfortable that you will be using always the same pattern for comments you can easily clean the string yourself before passing it to psycopg. A better approach for you I guess would be to use named placeholders, so that an a missing placeholder wouldn't require you to change the arguments to execute. -- Daniele On Tue, 26 May 2020 at 23:43, Frank Millman wrote: > > Hi all > > This is very minor, but I thought I would mention it. > > I have a function that returns a complex SQL query and a tuple of > parameters. The query is stored inside the function as a triple-quoted > string, and the parameters are derived depending on the input arguments. > > Sometimes while testing I will comment out some of the SQL using '--'. > If those lines happen to contain a parameter placeholder ('%s') I > expected to remove the parameter from the tuple as well. > > pyodbc and sqlite3 both work this way, but psycopg2 raises the exception > 'tuple index out of range'. > > I can live with it, but it means that I have to adjust the parameter > tuple differently depending on which database I am testing with. > > If it can be fixed, that would be nice. If it can't, no problem. > > Frank Millman > >