[ANN] pyPgSQL 2.1 released

Gerhard =?unknown-8bit?Q?H=E4ring?= gerhard.haering at gmx.de
Wed Jun 5 12:40:11 EDT 2002


CC-ing to pypgsql-users list, maybe other users have comments on this issue,
too.

* Paul Boddie <paul at boddie.net> [2002-06-05 08:21 -0700]:
> Gerhard <gh_pythonlist at gmx.de> wrote:
> > 	
> > * Fixed the array parsing so it also works with PostgreSQL versions 7.2.x.
> 
> I doubt that this is related, but does the 'IN' operator work with
> statement parameters (bind variables) in pyPgSQL yet? I recently found
> that doing something like this...
> 
>   cursor.execute("SELECT * FROM CAGES WHERE NAME IN %s",
>     (("mammals", "apes"),))
> 
> ...gives some kind of parsing error inside pyPgSQL.

It is indeed a related issue. If you want to show which queries pyPgSQL
produces, the trick is to access a special attribute like this:

conn.conn.toggleShowQuery

This would show the following query is executed:

QUERY: DECLARE PgSQL_08120A6C CURSOR FOR select * from cages where name in '{"mammals","apes"}'

... which obviously cannot work. The reason is that if pyPgSQL encounters a
tuple or a list in the statement parameters, it will quote them suitable for
use as an ARRAY. Unfortunately, the ARRAY syntax is different from what you
would need for the IN operator in SQL.

I'm not sure if something can be done about this problem. It seems to me that
it's an either/or with ARRAY vs. your desired conversion for the IN operator.

> [...] Another thing: pyPgSQL seems to be fine with Unicode query strings
> (unlike psycopg, apparently), but it doesn't like Unicode parameter values.
> Is there some explicit encoding step I should be performing?

I've fiddled with adding Unicode support for some time now, but I didn't get
enough testers yet to make me comfortable enough with it for adding it to a
pyPgSQL release. On the Sourceforge patches section, I've uploaded a patch for
full Unicode support, including getting Unicode results back from the database,
insert Unicode strings, and automatic encoding conversions. I'll try to update
this patch today to work with the latest pyPgSQL 2.1 release and drop you a
note when it's ready.

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: 25.7 °C      Wind: 4.5 m/s





More information about the Python-list mailing list