[PyQt] sql problems of a n00b

ionut cristian cucu cuciferus at gmail.com
Wed Sep 2 18:31:10 BST 2009


On Wednesday 02 September 2009 19:13:18 you wrote:
> Hi,
>
> maybe I can't understand your problem, but you never execute the query
> 'select * from pacienti where cnp = ?' before you jump into the error
> exception. First check, whether a=int(self.cautat.text()) is correct, then
> go on line by line.
well that was the intention...you see cnp is an int in sql and if the user's
input is a number I do a query for cnp if is a string I do a query by name.
It is executed since if int(self.cautat.text()) then print a gets twice
executed,but the except only once
>
> Hope this helps,
>
> Volker
>
> -------- Original-Nachricht --------
>
> > Datum: Wed, 2 Sep 2009 00:24:15 +0300
> > Von: ionut cristian cucu <cuciferus at gmail.com>
> > An: pyqt at riverbankcomputing.com
> > Betreff: [PyQt] sql problems of a n00b
> >
> > Hi list!
> > I have the following query:
> > try:
> >             a=int(self.cautat.text())
> >             self.query.prepare('select * from pacienti where cnp = ?')
> >             print self.query.executedQuery()
> >             self.query.addBindValue(QtCore.QVariant(a))
> >             print a
> >         except ValueError:
> >             self.query.prepare('select * from pacienti where nume=?')
> >         for k in 'b':
> >
> > self.query.addBindValue(QtCore.QVariant(QtCore.QString(self.cautat.text()
> >))) self.query.exec_()
> >
> > the thing is only the second prepare works, I've tried the first
> > select in a sqlite shell and works, furthermore the above code will
> > print a twice in a single execution....could you please give me a hint
> > on what I'm doing wrong here. (I've tried this on 2 machines and got
> > the same thing). Thanks!
> > _______________________________________________
> > PyQt mailing list    PyQt at riverbankcomputing.com
> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list