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]> |
This is my (temporary?) solution:
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() on the,
before entering critical sections of code.
"""
def __init__(self, ident):
self.ident = ident
self.ident_quoted = None
def prepare(self, conn):
self._conn = conn
def getquoted(self):
if not self.ident_quoted:
curs = self._conn.cursor()
curs.execute("SELECT quote_ident(%s)", (self.ident,))
self.ident_quoted = curs.fetchone()[0]
return self.ident_quoted
def __str__(self):
return str(self.ident_quoted)
Have fun,
federico
p.s. I haven't tested it!
--
Federico Di Gregorio http://people.initd.org/fog
DISCLAIMER. If I receive a message from you, you are agreeing that:
1. I am by definition, "the intended recipient".
2. All information in the email is mine to do with as I see fit and
make such financial profit, political mileage, or good joke as it lends
itself to. In particular, I may quote it on USENET or the WWW.
3. I may take the contents as representing the views of your company.
4. This overrides any disclaimer or statement of confidentiality that
may be included on your message.
_______________________________________________
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) iEYEABECAAYFAkmuj3UACgkQvcCgrgZGjeuyxwCeIPGcZ73C8oDEb50/XpNNebRe /m8An0jRbY7pj+dsr9jMOjudAHMeynrZ =nKeC -----END PGP SIGNATURE-----