Pass parameters to cursor.execute('Listen ')? - Mailing list psycopg

From Dumitru Melenteanu
Subject Pass parameters to cursor.execute('Listen ')?
Date
Msg-id 57442454.9020206@dekart.com
Whole thread Raw
Responses Re: Pass parameters to cursor.execute('Listen ')?
List psycopg
When performing LISTEN on a channel, passing parameters results in a
syntax error

    >>> cursor.execute('Listen %s', ('hello',))`

    ProgrammingError: syntax error at or near "'hello'"
    LINE 1: Listen 'hello'

The only way I could get it to work is to % format it, which seems to be
very frowned upon in the documentation, with good reason, and would
prevent using `executemany` for multiple channels.

    >>> cursor.execute('Listen %s'% ('hello',))

Is there any way to pass the channel as a parameter?


Attachment

psycopg by date:

Previous
From: Levente Kovacs
Date:
Subject: Re: install on windows
Next
From: Daniele Varrazzo
Date:
Subject: Re: Pass parameters to cursor.execute('Listen ')?