Re: Wierd "ProgrammingError" with "E" string prefix

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <[email protected]>
Il giorno mer, 04/03/2009 alle 21.51 +0100, Hartmut Goebel ha scritto:
> Federico Di Gregorio schrieb:
> 
> >> class Ident(object):
> >>     """Wrap a PostgreSQL identifier.
> >>
> >>     Note that this adapter need to make an SQL SELECT to correctly
> >>     quote the identifier (that is then cached) so it can be a good
> >>     idea to pre-allocate identifiers by calling getquoted(conn)
> >>     before entering critical sections of code (where `conn` is a 
> >>     valid connection.)
> >>     """
> 
> How is this meant to work?
> 
> >>> table_name = Ident('Table_One')
> >>> print cur.mogrify("DROP TABLE %s", (table_name,))
> ...
> psycopg2.ProgrammingError: can't adapt

Sorry, as I said I didn't tested it. Add this method to the class (and
add in "import psycopg2.extensions"):

def __conform__(self, proto):
    if proto == psycopg2.extensions.ISQLQuote:
        return self

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
  We are all dust, Saqi, so play the lute
                    We are all wind, Saqi, so bring wine. -- Omar Khayam

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkmu+5QACgkQvcCgrgZGjesIPQCfXSsU0xfFOXNzag4YF/WbKdu/
CQ8An3shNLkSynk5YD1Lru50aN51Ts9Y
=s9se
-----END PGP SIGNATURE-----
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.