Hi all, I am trying to do a count on a particular table :
session.query(User).count() To get the number of User objects in the database. I am getting the exception below : return self.session.query( File "c:\python24\lib\site-packages\SQLAlchemy-0.4.6-py2.4.egg \sqlalchemy\orm\ query.py", line 1075, in count return q._count() File "c:\python24\lib\site-packages\SQLAlchemy-0.4.6-py2.4.egg \sqlalchemy\orm\ query.py", line 1084, in _count return self._col_aggregate(sql.literal_column('1'), sql.func.count, nested_c ols=list(self.mapper.primary_key)) File "c:\python24\lib\site-packages\SQLAlchemy-0.4.6-py2.4.egg \sqlalchemy\orm\ query.py", line 1103, in _col_aggregate return self.session.scalar(s, params=self._params, mapper=self.mapper) File "c:\python24\lib\site-packages\SQLAlchemy-0.4.6-py2.4.egg \sqlalchemy\orm\ session.py", line 632, in scalar return self.__connection(engine, close_with_result=True).scalar(clause, para ms or {}) File "c:\python24\lib\site-packages\SQLAlchemy-0.4.6-py2.4.egg \sqlalchemy\orm\ session.py", line 597, in __connection return self.transaction.get_or_add(engine) File "c:\python24\lib\site-packages\SQLAlchemy-0.4.6-py2.4.egg \sqlalchemy\orm\ session.py", line 199, in get_or_add self._assert_is_active() File "c:\python24\lib\site-packages\SQLAlchemy-0.4.6-py2.4.egg \sqlalchemy\orm\ session.py", line 166, in _assert_is_active raise exceptions.InvalidRequestError("The transaction is inactive due to a r ollback in a subtransaction and should be closed") sqlalchemy.exceptions.InvalidRequestError: The transaction is inactive due to a rollback in a subtransaction and should be closed I am running this test in a multi threaded environment. Each of them has a separate session object. Two of the threads (one is the Main Thread itself) add users to the db, and the other two modify the objects added to the database. The Main Thread prints a reporting line after adding 50 objects which contains the info of how many User objects are there in the DB. The above query is executed in this context. The exception I get above is not consistent, that is, sometimes it comes after the first 50 records, sometimes after 200 and sometimes after 250. The session is transactional with autoflush=False. Why is a query trying to find out the status of session? Is there anything that could have been done wrong? Thanks in advance for the help! Cheers, Harish --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---