Re: Error in PostgreSQL query with psycopg

From: "Harald Armin Massa" <haraldarminmassa(at)gmail(dot)com>
To: Parthan <parth(dot)technofreak(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Error in PostgreSQL query with psycopg
Date: 2006-07-31 20:30:55
Message-ID: 7be3f35d0607311330n2801cae3u3ccaef26cb47b74e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Parthan,

never, never, never try quoting on your own! You can only fail. The only
choice is to fail now or later.

The only recommended way with Python and DBAPI2.0 is:

lala="huibuh"
cs.execute ("select bla from foo where schupp=%s", (lala,))

or better

cs.execute ("select bla from foo where schupp=%(lala)s",
dict(lala="huibuh"))

(that's with psycopg2)

Harald

--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Reinsburgstraße 202b
70197 Stuttgart
0173/9409607
-
Let's set so double the killer delete select all.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-07-31 20:57:42 Re: Corrupted DB? could not open file pg_clog/####
Previous Message Christian Kastner 2006-07-31 20:18:31 Re: pg_xlog not cleaned up