I think so your problem is in this line: rowCounter = rowCounter.filter(and_(getattr(MaterialsTable,attr).like("%%%s%%" % val))).count()
Here you put a integer in your rowCounter variable, then in your next call of this the don't have a filter method in your rowCounter ;) Em quinta-feira, 12 de setembro de 2013, Mohsen Pahlevanzadeh escreveu: > 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 <javascript:_e({}, > 'cvml', 'sqlalchemy%2bunsubscr...@googlegroups.com');>. > To post to this group, send email to > sqlalchemy@googlegroups.com<javascript:_e({}, 'cvml', > 'sqlalchemy@googlegroups.com');> > . > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/groups/opt_out. > -- paz e amor (love and peace), Alysson Bruno =============================================== Palmas(TO) Brasil Blog: http://abruno.com Twitter: http://twitter.com/alyssonbruno Facebook: http://www.facebook.com/ProfessorAlyssonBruno ================================================================= *Meu alterego Escritor:* Leia alguns contos que escrevo, não esqueça de me dar sua opinião: http://goo.gl/Wjn4p <http://goo.gl/AXv1g> ================================================================= -- 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.