From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0 Description of problem: #!/usr/bin/python import ensimapplpath from appldb import * def select_site(site_id): try: db=opendb() c=db.cursor() #c.execute("select * from siteinfo where site_id=%(siteid)d" , {'siteid':site_id}) c.execute("""select * FROM siteinfo WHERE site_id = %(siteid)d""",{'siteid': site_id}) result=c.fetchone() print result c.close() closedb(db) except DBError_ext, errval: raise DBError(str(errval)) if __name__ == "__main__": select_site(1) ============================================================================== Traceback (most recent call last): File "test.py", line 52, in ? select_site(1) File "test.py", line 16, in select_site raise DBError(str(errval)) appldb.DBError: internal error in 'INIT' =============================================================================== original pgdb.py code for postgresql-python-7.4.6-1.RHEL4.2 on RHEL4ES =============================================================================== def _quote(x): if type(x) == DateTime.DateTimeType: x = str(x) if isinstance(x, types.StringType): x = "'" + string.replace( string.replace(str(x), '\\', '\\\\'), "'", "''") + "'" elif type(x, (types.IntType, types.LongType, types.FloatType)): pass elif x is None: x = 'NULL' elif type(x, (types.ListType, types.TupleType)): x = '(%s)' % string.join(map(lambda x: str(_quote(x)), x), ',') elif hasattr(x, '__pg_repr__'): x = x.__pg_repr__() else: raise InterfaceError, 'do not know how to handle type %s' % type(x) return x =============================================================================== original pgdb.py code for postgresql-python-7.4.6-1.FC2.2 on FC2 =============================================================================== def _quote(x): if isinstance(x, DateTime.DateTimeType): x = str(x) if isinstance(x, types.StringType): x = "'" + string.replace( string.replace(str(x), '\\', '\\\\'), "'", "''") + "'" elif isinstance(x, (types.IntType, types.LongType, types.FloatType)): pass elif x is None: x = 'NULL' elif isinstance(x, (types.ListType, types.TupleType)): x = '(%s)' % string.join(map(lambda x: str(_quote(x)), x), ',') elif hasattr(x, '__pg_repr__'): x = x.__pg_repr__() else: raise InterfaceError, 'do not know how to handle type %s' % type(x) return x ============================================================================= The following part is giving the problem when dictionary is passed to the execute statement as described in the above example. elif type(x, (types.IntType, types.LongType, types.FloatType)): Version-Release number of selected component (if applicable): postgresql-python-7.4.6-1.RHEL4.2 How reproducible: Always Steps to Reproduce: 1. create the test.py file 2. run the test.py file (python test.py) 3. error will be dumped on the prompt Actual Results: Traceback (most recent call last): File "test.py", line 52, in ? select_site(1) File "test.py", line 16, in select_site raise DBError(str(errval)) appldb.DBError: internal error in 'INIT' Expected Results: [1, 'niket.com', 'll', 's'] which is the entry present in the database. Additional info: on Fedora Core 2 the code is working fine. For RHEL4ES the code has been changed in the pgdb.py file.
This is fixed in 7.4.7-1.RHEL4.1 and later, I believe. *** This bug has been marked as a duplicate of 142711 ***