vendredi 25 septembre 2015

Python and Sqlite3 return more than one line

I'm trying to do a query in sqlite with python, but when I do the research in my database it's just return the last input. Like this

def Busca(self):
        conn = sqlite3.connect('teste.db')
        cursor = conn.cursor()

        valorAtual = str(self.comboBox.currentText())
        if valorAtual == "CNPJ":
            sqlqry = 'SELECT * FROM OrdemServico WHERE CNPJ =' + self.lineEdit_9.text()
            c = cursor.execute(sqlqry)
            retorno = str(c.fetchone())
            retorno = retorno.replace("'","")
            self.textEdit.setText(retorno)

So this query in sqlite browser returns three values, but in python it just return one.

Does anybody know why?

Aucun commentaire:

Enregistrer un commentaire