Dear all, I have the following code: ////////////////////////////////////////////////////////////////// query = self.dbObj.session.query(MaterialsTable) rowCounter = self.dbObj.session.query(MaterialsTable) for attr , val in interfaceCodesObject.filterNameDict.items(): query = query.filter(and_(getattr(MaterialsTable,attr).like("%%%s%%" % val))) rowCounter = rowCounter.filter(and_(getattr(MaterialsTable,attr).like("%%%s%%" % val))).count() query.all() /////////////////////////////////////////////////////////////////////////////
When i use mutiple field, i get the following traceback: /////////////////////////////////////////////////////// Traceback (most recent call last): File "/home/mohsen/codes/amlak/amlak/src/ui/materialsFindFrame.py", line 202, in <lambda> QtCore.QObject.connect(self.pushButtonSearch, QtCore.SIGNAL(_fromUtf8("clicked()")), lambda: self.interfaceCodesConstructor.responseToRequestForData(self)) File "/home/mohsen/codes/amlak/amlak/src/ui/interface/interface.py", line 109, in responseToRequestForData self.materialsObejct.findData(self.objectSearchMaterials,self) File "/home/mohsen/codes/amlak/amlak/src/materials/materials.py", line 133, in findData rowCounter = rowCounter.filter(and_(getattr(MaterialsTable,attr).like("%%%s%%" % val))).count() AttributeError: 'long' object has no attribute 'filter' /////////////////////////////////////////////////////////////////////////////// But when i use just one field it use rowCounter as integer and real return. My question is , how can i adapt it with multiple field? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.