Davide Alberani | 3 Jan 14:32 2010
Picon

problem setting charset for a postgresql db (psycopg2)

I'm probably missing something very simple. :-)
SQLObject from the SVN (but also 0.12), psycopg2 2.0.13, Python 2.5,
Postgresql 8.4.2 on a Debian sid.

Test code:
===================================================
from sqlobject import *

connection = connectionForURI('postgres://root:q1w2e3 <at> localhost/imdb?charset=UTF-8')

class TestTableName(SQLObject):
    testColName = StringCol()

TestTableName.setConnection(connection)
TestTableName.createTable(True)
===================================================


Error:
===================================================
Traceback (most recent call last):
  File "./pino", line 13, in <module>
    TestTableName.createTable(True)
  File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/main.py", line 1404, in createTable
    if ifNotExists and cls.tableExists(connection=conn):
  File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/main.py", line 1378, in tableExists
    return conn.tableExists(cls.sqlmeta.table)
  File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/postgres/pgconnection.py", line 191, in tableExists
    % self.sqlrepr(tableName))
  File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/dbconnection.py", line 392, in queryOne
    return self._runWithConnection(self._queryOne, s)
  File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/dbconnection.py", line 260, in _runWithConnection
    conn = self.getConnection()
  File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/dbconnection.py", line 271, in getConnection
    conn = self.makeConnection()
  File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/postgres/pgconnection.py", line 139, in makeConnection
    conn.query("SET client_encoding TO %s" % dbEncoding)
AttributeError: 'psycopg2._psycopg.connection' object has no attribute 'query'
===================================================



Thanks in advance!
--
Davide Alberani <da <at> mimante.net>  [PGP KeyID: 0x465BFD47]
http://www.mimante.net/

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytman | 3 Jan 15:15 2010
X-Face
Picon

Re: problem setting charset for a postgresql db (psycopg2)

On Sun, Jan 03, 2010 at 02:32:06PM +0100, Davide Alberani wrote:
>     conn.query("SET client_encoding TO %s" % dbEncoding)
> AttributeError: 'psycopg2._psycopg.connection' object has no attribute
> 'query'

   The bug has already been reported in the SF tracker. I will fix it RSN.

Oleg.
--

-- 
     Oleg Broytman            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 

Gmane