loading data from database using another thread
-
@KroMignon : you must not move access a QSqlDatabase from a different thread!
@Christian-Ehrlicher said in loading data from database using another thread:
you must not move access a QSqlDatabase from a different thread!
Yes I know, but this is only the result of the request, there are no SQL statement which will be handled. Only the result of the old request.
What's wrong with this? -
@Christian-Ehrlicher said in loading data from database using another thread:
you must not move access a QSqlDatabase from a different thread!
Yes I know, but this is only the result of the request, there are no SQL statement which will be handled. Only the result of the old request.
What's wrong with this?@KroMignon
hi bro again
is there any solution
with const lambdawhile(qry.next()){ // error here counters +=qry.value(colCounter).toFloat(); }
it says this error !
'this' argument to member function 'next' has type 'const QSqlQuery', but function is not marked const
qsqlquery.h:92:10: note: 'next' declared here -
@KroMignon
hi bro again
is there any solution
with const lambdawhile(qry.next()){ // error here counters +=qry.value(colCounter).toFloat(); }
it says this error !
'this' argument to member function 'next' has type 'const QSqlQuery', but function is not marked const
qsqlquery.h:92:10: note: 'next' declared here@Proton-Phoenix said in loading data from database using another thread:
is there any solution
with const lambdaNo, you cannot use
QSqlQuery::next()
, with a const instance. -
thank you bro
when i add mutable problem Disappeared .. and it loads data from another thread successfully Finally :DReally Thank you guys
QFuture<float> future = QtConcurrent::run([qry]()mutable ->float {
-
@Christian-Ehrlicher said in loading data from database using another thread:
you must not move access a QSqlDatabase from a different thread!
Yes I know, but this is only the result of the request, there are no SQL statement which will be handled. Only the result of the old request.
What's wrong with this?@KroMignon said in loading data from database using another thread:
Yes I know, but this is only the result of the request, there are no SQL statement which will be handled. Only the result of the old request.
What's wrong with this?QSqlQuery does not have the data, it only fetches the data when you call e.g. next() so it still uses the database connection.
-
@KroMignon said in loading data from database using another thread:
Yes I know, but this is only the result of the request, there are no SQL statement which will be handled. Only the result of the old request.
What's wrong with this?QSqlQuery does not have the data, it only fetches the data when you call e.g. next() so it still uses the database connection.
@Christian-Ehrlicher said in loading data from database using another thread:
QSqlQuery does not have the data, it only fetches the data when you call e.g. next() so it still uses the database connection.
Indeed, that's sound bad :(
I misunderstood howQSqlQuery
works, I believe it launch the request and store the result locally. -
@KroMignon said in loading data from database using another thread:
I believe it launch the request and store the result locally.
This would be a very bad behavior for large result sets.
-
@KroMignon said in loading data from database using another thread:
I believe it launch the request and store the result locally.
This would be a very bad behavior for large result sets.
@Christian-Ehrlicher said in loading data from database using another thread:
This would be a very bad behavior for large result sets.
You are right.
This will made this a little bit more complex, because the SQL connection have to leave in another thread, which means a new DB connection is required. -
@Christian-Ehrlicher said in loading data from database using another thread:
This would be a very bad behavior for large result sets.
You are right.
This will made this a little bit more complex, because the SQL connection have to leave in another thread, which means a new DB connection is required.@KroMignon Or do only the calculation in the other thread.
-
@KroMignon Or do only the calculation in the other thread.
@Christian-Ehrlicher
do i need to change anything??? -
@KroMignon Or do only the calculation in the other thread.
@Christian-Ehrlicher and @KroMignon
i did it successfully Thanks you so much your opinions helped me to fix the Big O problem too
now it's only calculation with the other thread
<3