Roland Koebler | 1 Jun 2008 16:51
Picon
Favicon

PgArrays and Unicode ?

hi,

I tried to insert unicode-values into a PostGreSQL-array, but
unfortunately that did not work but raised an UnicodeEncodeError (see
below). so:
- is is right, that pyPgSQL doesn't support unicode in arrays?
- if yes, how can this be solved?

here's the examle:

assume the following PostGreSQL-table:
    CREATE TABLE test (
	arr varchar[]
    );

now in python:
    >>> from pyPgSQL import PgSQL
    >>> db = PgSQL.connect(database='test', user='test', password='test',
client_encoding=('UTF-8','ignore'), unicode_results=1)
    >>> cu = db.cursor()
    >>> cu.execute(u"""INSERT INTO test (arr) VALUES(%s)""", PgSQL.PgArray([u'ä']))
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "/usr/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line 3086, in execute
	parms = tuple(map(_quote, self.__unicodeConvert(parms)));
      File "/usr/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line 2257, in _quote
	return value._quote()
      File "/usr/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line 1328, in _quote
	return _handleArray(self.value)
      File "/usr/lib/python2.4/site-packages/pyPgSQL/PgSQL.py", line 2239, in _handleArray
(Continue reading)


Gmane