In my server code, there is a call to _SO_fetchAlternateID
(nested in some value
call), which ultimately calls makeConnection
in pgconnection.py
.
This call fails on conn.autocommit(1)
, with the error
TypeError: 'bool' object is not callable
Here is SQLObject's (0.8.7) code:
def makeConnection(self):
try:
if self.use_dsn:
conn = self.module.connect(self.dsn)
else:
conn = self.module.connect(**self.dsn_dict)
except self.module.OperationalError, e:
raise self.module.OperationalError("%s; used connection string %r" % (e, self.dsn))
if self.autoCommit:
# psycopg2 does not have an autocommit method.
if hasattr(conn, 'autocommit'):
conn.autocommit(1)
return conn
Debugging shows that conn indeed holds a connection object, but autocommit is not a method but instead a boolean (False).
self.module
is module 'psycopg2' (2.4.2).
Is this a configuration issue? mismatching versions?
UPDATE:
The cause turns out to be an incompatibility issue in psycopg2-2.4.2. Looking at the C source code, psycopg/connection.h has an integer variable unfortunately named autocommit
. Version 2-2.4 works ok.