Data entered into Sqlite3 is not shown in the Pyqt4 application

Asked

Viewed 45 times

0

I made a small Pyqt4 desktop application where I insert data in db sqlite3, but when I go to consult this data that was inserted previously, they are not on the display screen of them, only when I exit the application and enter again to make the query is that the data appears. I can’t identify why this is happening, could anyone help me in this case? Below, part of the data insertion code in DB.

sql_ins_dados_q = "INSERT INTO quinas(concurso,data_sorteio,bola_1,bola_2,bola_3,bola_4,bola_5,arrecadacao,ganhadores_quina,rateio_quina,ganhadores_quadra,rateio_quadra,ganhadores_terno,rateio_terno) 
                   VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"

while i < len(trt_htm_q.concursos):
    insere_dados_q.cur.execute("PRAGMA synchronous = OFF")
    insere_dados_q.cur.execute(sql_ins_dados_q,(trt_htm_q.concursos[i],
                                                trt_htm_q.concursos[i+1],
                                                trt_htm_q.concursos[i+2],
                                                trt_htm_q.concursos[i+3],
                                                trt_htm_q.concursos[i+4],
                                                trt_htm_q.concursos[i+5],
                                                trt_htm_q.concursos[i+6],
                                                trt_htm_q.concursos[i+7],
                                                trt_htm_q.concursos[i+8],
                                                trt_htm_q.concursos[i+9],
                                                trt_htm_q.concursos[i+10],
                                                trt_htm_q.concursos[i+11],
                                                trt_htm_q.concursos[i+12],
                                                trt_htm_q.concursos[i+13]))
    i += 14
    c += 1
insere_dados_q.conn.commit()
insere_dados_q.cur.close()
insere_dados_q.conn.close()
  • 1

    I find it very difficult to help you without seeing any of your code - read this.

  • Can you make a connection by prompt to db as soon as you insert it, to see if the data is there? (before closing the program)

  • Daniel, I did everything by pyqt and I don’t even know how I would make this connection via prompt.

  • Daniel, I edited the question by placing the part of the data insertion code in DB.

  • 1

    So the data is displayed in the application, just reopen it, right? If yes, the error will not be in the insertion of the data, but in the way you are displaying it, needing, in this case, the code of QT4.

  • Enter the pyqt code as indicated by Anderson... ;)

  • I have found that the problem is not with the query of the data that has been entered, I am sorry. The problem occurs when I will manipulate these data type, some statistics, I checked that when I run for example the most randomly selected pairs/odd, the data diverges when I close and open the application again. So the problem is there. I’ll check the question of opening/closing the database, it might be right.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.