+ 1

Progress Bar doesn't update incrementally

Hi, I am writing a utility in a script language called KVS which is for the KVIrc IRC client. It's a little obscure, I know, but it is based on Qt. I have written code that opens a text file, reads the file line by line, and each line is sent as a query to a sqlite database using the SQL library that KVS has built in. afaik, it's just a standard sqlite3 library that Qt would have. I wanted to have a progress bar widget to show the progress of this loop. If I comment out the calls to the SQL object to send the queries, the code executes so fast that I can't see the progress bar working. If I include the SQL calls, the utility "hangs" (Not Responding in Windows) while it executes all the database calls (there's about 1100 lines i;m working with) and the widgets don't update until the loop finishes. So either way I go, I can't see the progress widget updating. Is there some general way I can slow up the processing for testing to see if the widget will redraw correctly? And since the scripting language is using a SQL library to access the database, is this a common problem when using databases? Is there some way I can work around the "Not Responding" hang state while the loop processes my data?

3rd Jun 2020, 2:41 AM
Nathan Stanley
Nathan Stanley - avatar
6 ответов
+ 1
As long as you are not working with a single transaction for all lines, SQLite or its library should not block anything. To slow down add a sleep or a useless calculation.
3rd Jun 2020, 2:51 AM
Sandra Meyer
Sandra Meyer - avatar
+ 1
Do you commit each insert separately?
3rd Jun 2020, 3:02 AM
Sandra Meyer
Sandra Meyer - avatar
+ 1
Perfect, then I'm confused of this too. Slow it down, calculate something interesting, your age in ms or sth. like that 🙃
3rd Jun 2020, 3:08 AM
Sandra Meyer
Sandra Meyer - avatar
0
@Sandra when you say a "single transaction for all lines" do you mean sending all the lines (each line is an INSERT) in a single transaction, or do you mean sending EACH line as a query? I am not using transactions, I am sending each line as it's own SQL query, which is why i thought i could easily just update the progress bar every time the query completed.
3rd Jun 2020, 2:59 AM
Nathan Stanley
Nathan Stanley - avatar
0
@Sandra Yes, each insert is committed separately.
3rd Jun 2020, 3:06 AM
Nathan Stanley
Nathan Stanley - avatar
0
I slowed it down and the progressbar widget was updating correctly, but id just seems to not update when the SQLite calls are being made. I have no idea why. I am going to try to convert this project over to C++ with Qt now that I have it built in KVS.
3rd Jun 2020, 5:18 AM
Nathan Stanley
Nathan Stanley - avatar