Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 9E2E32E0085 for ; Sun, 27 Apr 2008 13:54:25 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 29860-09 for ; Sun, 27 Apr 2008 13:54:15 -0300 (ADT) X-Greylist: delayed 01:00:11.090414 by SQLgrey-1.7.5 Received: from vms173001pub.verizon.net (vms173001pub.verizon.net [206.46.173.1]) by developer.postgresql.org (Postfix) with ESMTP id 56B4D2E006D for ; Sun, 27 Apr 2008 13:54:16 -0300 (ADT) Received: from [192.168.2.5] ([71.180.197.65]) by vms173001.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JZZ00DBGQTLZ577@vms173001.mailsrvcs.net> for pgsql-sql@postgresql.org; Sun, 27 Apr 2008 10:53:47 -0500 (CDT) Date: Sun, 27 Apr 2008 11:55:18 -0400 From: Joe Subject: Re: Protection from SQL injection In-reply-to: <20080427142253.449de600@dawn.webthatworks.it> To: Ivan Sergio Borgonovo Cc: pgsql-sql@postgresql.org Message-id: <4814A1E6.1070200@freedomcircle.net> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII; format=flowed Content-transfer-encoding: 7bit References: <5f211bd50804260932l7a63618jca64858271ff269f@mail.gmail.com> <13670.1209267734@sss.pgh.pa.us> <20080427123848.5c841788@dawn.webthatworks.it> <20080427142253.449de600@dawn.webthatworks.it> User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/203 X-Sequence-Number: 30742 Ivan Sergio Borgonovo wrote: > It'd be nice to have a wrapper that let you write prepared statements > this way: > > "select a.id, b.name from a join b on a.id=b.id where > a.status=$variable1 and b.id>$variable2 etc... but that's a pretty > good change to any language parser. > Python already supports something like that. See PEP 249 (http://www.python.org/dev/peps/pep-0249/), under Module Interface, the description of the paramstyle parameter. Psycopg2 supports both the "format" (C printf) and "pyformat" styles. See the last section on this page for an example using the pyformat style: http://www.devx.com/opensource/Article/29071/0/page/3. Joe