Python和Sqlite3返回多个lin

2024-05-08 11:06:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用python在sqlite中进行查询,但是当我在数据库中进行研究时,它只返回最后的输入。像这样

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)

所以sqlite浏览器中的这个查询返回三个值,但在python中它只返回一个值。你知道吗

有人知道为什么吗?你知道吗


Tags: self数据库sqlitedefconnectconnsqlite3cursor

热门问题