PDA

View Full Version : QSqlQuery Exec and QProgressBar Update



zerokewl
7th September 2013, 10:34
Hello,

I am uploading/downloading BLOB files into a MySQL Database and it works well with small files. However BLOB sizes in MySQL can go upwards to 2GB per entry in a database, and i want to allow my application to upload up to that limit. At the moment when i upload a small file, using a QSqlQuery.bindValue and QSqlQuery.prepare, it works. But when i try to upload a larger file, it hangs until its done.

Now i can separate it so it doesn't hang using a QObject.movetoThread() and doing my work in that thread, but what I'm really looking for is a way to bind a signal/slot from the QSqlQuery.exec() to a ProgressDialog.setValue() .

Do i have to subclass a QSqlQuery and rewrite something there, or is there another way?

I want to show the user, something is either being uploaded, or downloaded with a progress bar, and also put a cancel button there if they want to stop it.

I know if this was a QIODevice, i could use bytesWritten for such progress display, is there anything similar for QSqlQuery and Exec?

Thank you.

Lesiok
7th September 2013, 13:08
I don't think that MySQL driver can do this so QSqlQuery also can not.

zerokewl
7th September 2013, 13:39
Hello, Thank you for your reply. That would make sense if the driver didn't have that capability. :-(

Ok in that case, if the Driver doesn't allow it.. I don't know how to rewrite a driver... But, MYSQL you can CONCAT which is a way to Append the data, so im going to try splitting a file first, and appending it and updating the QProgressDialog as i go. This way might be sufficient.

The idea is to split a 100MB file into 1MB bits, and after each upload, report back and update the QProgressDialog. At least this way we will see some form of Progress Downloading and Uploading.

Any thoughts?

Thank you.

Edit: After reading this (http://grokbase.com/t/mysql/mysql/996xt29byb/blobs-and-concat) maybe it is not such a good idea to keep appending to a blob in such a way. Might have to just have a permanent Progress bar in IDLE State to indicate some action is taking place, and alert the user, larger files will take time to send!

If anyone else has any thoughts, please let me know.

Thank you.