Re: Error in a simple query (SOLVED) - Mailing list psycopg

From Daniele Varrazzo
Subject Re: Error in a simple query (SOLVED)
Date
Msg-id CA+mi_8ZUpRds--M3uAoHNK4pwoxO7hK5DF73ntHYCBAYTjBk1A@mail.gmail.com
Whole thread Raw
In response to Re: Error in a simple query (SOLVED)  (Gustavo <gmpuljak@yahoo.com.ar>)
List psycopg
On Tue, Jun 25, 2013 at 12:18 AM, Gustavo <gmpuljak@yahoo.com.ar> wrote:
> Adrian,
>
> thanks for the hint. The script was processing data from a txt file with
> several thousand lines and the problem was in a malformed insert from the
> bottom of the previous iteration.

No: the error is that you are composing the query manually instead of
letting psycopg joining the arguments to the query, as cleanly
documented at the very beginning of the manual, from the very first
example.

http://initd.org/psycopg/docs/usage.html

The page explains in details why running

>> > a = """select idbalizas from nuevo.balizas where %s %s %s %s""" % (emp1,
>> > dnid1, mem1, mmsi1)
>> > print
>> > cur.execute(a)

is an amazingly bad idea.


-- Daniele


psycopg by date:

Previous
From: Gustavo
Date:
Subject: Re: Error in a simple query (SOLVED)
Next
From: Daniele Varrazzo
Date:
Subject: Problem with the default registration of the JSON adapter