Re: auto escaping "NULL"

Adrian Klaver <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Thursday 03 December 2009 3:24:51 pm Jacob Joseph wrote:
> Hi.
> Upon trying to insert NULL values into a double precision field, I
> receive the error:
>
> DataError: invalid input syntax for type double precision: "NULL"
> LINE 4:         (2, -1, E'NULL', 1.11,
>
> I'm using a statement like:
> curs.execute("INSERT INTO foo (distance) VALUES (%(dist)s)", {'dist':
> None})
>
> Should I expect this statement to work?  Removing the quotes from NULL
> seems to be correct.

Works for me. 

>
> As a related question, what is the correct way to use the execute(s,
> args) syntax, but *not* escape a particular variable?  Not so
> infrequently, I'd like to use an argument to add an SQL command, such
> as adding to a WHERE or specifying a field.

>
> (I'm using 2.0.12 and postgres 8.4.)
>
> Thanks,
> ~Jacob



-- 
Adrian Klaver
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.