Skip to content
  • 0 Votes
    20 Posts
    617 Views
    JonBJ
    @dviktor I looked at your "minimal" repro. The queries are horrendously long and complex, and require many tables with many columns. If I were you and I wanted help/someone to look at it I would spend my time reducing to an absolute minimum, e.g. does it require a JOIN at all, does it show up with one JOIN, do I really need a calculated column, do I need MAX() or other "aggregate", does it matter whether a column is DATE versus DATETIME, does the WHERE clause matter, etc. I would hope to produce the absolute minimum code and database where I could say: "if you run this query it works fine but as soon as I make just this one little change it goes wrong". Up to you.
  • 0 Votes
    5 Posts
    940 Views
    D
    @Christian-Ehrlicher I solved the problem. After digging deeper, I found that in the function QMYSQLResult::reset(const QString& query) in the source code qsql_mysql.cpp, the field type of all data was set to the default value MYSQL_TYPE_DECIMAL(0). Also, I saw that it was loading another libmariadb.dll from the list of loaded dlls, which I had not specified. Eventually, I decided to start over, and after deleting Qt, MariaDB, MariaDB connector, and environment variables, rebuilding, installing, and building the plugin, it finally worked fine. I still don't know exactly what the problem was, but thank you for your attention.
  • 0 Votes
    10 Posts
    1k Views
    JonBJ
    @Christian-Ehrlicher said in QSql performance consideration/data flow design.: Ok, I would never consider those functions as replacement for stored procedure. I agree, but it is their documentation, I guess "Lite" means "lite" :)
  • QSqlQuery does not return a record set?

    Solved General and Desktop qsqlquery results
    7
    0 Votes
    7 Posts
    925 Views
    J
    @Christian-Ehrlicher Thanks!!
  • 0 Votes
    20 Posts
    3k Views
    JonBJ
    @swankster :) Like I said, just build the (correct, including whatever quoting, and if you are OK on possible SQL injection attacks!) string and pass that without using binding, for this query.
  • 0 Votes
    5 Posts
    1k Views
    JonBJ
    @Narutoblaze Then no you cannot, as you can see in the documentation for QTcpSocket/ QAbstractSocket. If there were a method which took a "connection name" you would see it documented. There is nothing to stop you writing your own code to store connections indexed by some "connection name" you choose, e.g. using a QMap Class.
  • SQL WHERE Clause In QSqlQuery::setQuery( )

    Solved Qt 6 qsqlquery qsqlquerymodel tableview
    11
    0 Votes
    11 Posts
    2k Views
    Pl45m4P
    @Donald9307 Just to clear the confusion, do you have any model or in which way do you use your query? Because there is no QSqlQuery::setQuery() (as in the title). But good to hear that it worked for you :)
  • 0 Votes
    9 Posts
    1k Views
    K
    I have worked with the qsqlcipher plugins well and gone through with the qsqlcipher plugin code and I puted some print statement in the plugin code itself then observed that the fetchNext function taking is more time, Please look into it
  • 0 Votes
    14 Posts
    3k Views
    D
    @RyanSolanki Please mark as solved if you are happy the issue is resolved. Also consider reading up further about Qt's memory management model (maybe it would make sense to pass a parent during the QSqlQueryModel's construction to avoid all that manual memory management or else perhaps smart pointers if there is no clear parent to assign ownership to). Furthermore, SGaist's point about passing a pointer to a function whose signature expects a const reference cannot be understated. If the function expects a pointer, give it a pointer. If it expects a const reference, give it an object created on the stack! https://doc.qt.io/qt-5/qsqlquerymodel.html#details The documentation is good; use it! It is unclear to me why you are using functions such as "clear" for the model. The setQuery() function already clears the model. Why mess around with new and delete several times when you can just pass in a new query to modify the existing model? Futhermore, why bother clear()-ing the model immediately before you delete it? The destructor is called during the delete, which itself frees up any resources, per the documentation. There are deeper problems of comprehension going on here!
  • Copies of QSqlQuery share the same bound values

    Solved General and Desktop qsqlquery copying
    7
    0 Votes
    7 Posts
    1k Views
    Christian EhrlicherC
    Thx. Will take a look on it and hope it will go into 5.15 (even we as opensource user currently don't have an advantage currently but this hopefully changes somehow in the near future)
  • Store custom QVariant type in database

    Solved General and Desktop qsql qsqlquery qvariant
    6
    0 Votes
    6 Posts
    2k Views
    JKSHJ
    @Max13 said in Store custom QVariant type in database: I will write a toJson() instead, as I'm loading the data from Json already. Sounds good. Thanks for your advice. Indeed, it would be the correct way to implement this, in my situation I didn't think it would be necessary to implement it that way. I'm updating some models from an API, and save them as a read-only cache in an sqlite because the desktop may be disconnected. So in my opinion, adding another table would make me write more queries and deal with relations when I can do that in a nasty way 😅 That's fair enough. Simplicity is often a good thing in code. Thanks for your complete answer. You're most welcome. Happy coding!
  • QSqlquery exec timeout

    Unsolved General and Desktop qsqldatabase qsqlquery timeout exec qt 5.12
    5
    0 Votes
    5 Posts
    2k Views
    BartoszPajB
    Process still block, when I lost connection.
  • calling stored procedure with prepared query vs execute

    Unsolved General and Desktop qsqlquery
    9
    0 Votes
    9 Posts
    4k Views
    D
    @Kent-Dorfman said in calling stored procedure with prepared query vs execute: Since a stored procedure is simply a server-side wrapper around an SQL transaction, it is IRRELEVANT AND REDUNDANT to wrap it in a prepared statement on the client. Yes, I start to understand what you mean. I will study in deep this argument. Thanks a lot for your precious comments.
  • SQLQuery Like problem

    Solved General and Desktop qsqlquery binding
    3
    0 Votes
    3 Posts
    2k Views
    G
    @SGaist My bad ! I did not think to check the docs on that point ! A big thanks Gérard
  • BindValue() in QPSQL is not working?

    Solved General and Desktop qsqlquery postgresql sqldriver sql
    13
    0 Votes
    13 Posts
    4k Views
    Christian EhrlicherC
    @bartoszpaj said in BindValue() in QPSQL is not working?: driver()->hasFeature(QSqlDriver::NamedPlaceholders) returns false. Good catch. I think it's because support for PostgreSQL 10 was added in a later version. If the version is not known to the driver it will fall back to the oldest.
  • 0 Votes
    17 Posts
    7k Views
    A
    @SGaist I did it this way for reading return params: Query.nextResult(); // after reading table values //Get Return Parameter for (int i=0; i<CountReturnParam; i++) { qDebug() << QString("Returnparam %1 = %2") .arg(i).arg(Query.boundValue(i).toString()); }
  • 0 Votes
    3 Posts
    2k Views
    SGaistS
    Hi, There’s also no need to allocate the query on the heap as the QSqlQueryModel::setQuery method parameter suggests.
  • 0 Votes
    4 Posts
    2k Views
    SGaistS
    As it is now, double is used. Depending on how your DECIMAL filed is configured, it might be enough. If not, then you can modify the plugin to read the field as described here.
  • Cannot retrieve the SQL query string from QSqlQuery?

    Solved General and Desktop qsqlquery
    6
    0 Votes
    6 Posts
    6k Views
    JonBJ
    @jsulm said in Cannot retrieve the SQL query string from QSqlQuery?: @mostefa This is not the answer to the question as @JNBarchan want to have the query text not its result. From your example he wants to get "SELECT id,name,birthday FROM artist". @mostefa As @jsulm says, I am indeed not looking to execute the query, rather only to retrieve its text. This has indeed turned out to be QSqlQuery::lastQuery(), and I have now marked this question as Solved. Thanks all.
  • Ask for help (maybe) in query.value(0).

    Solved General and Desktop qsqlquery mysql select
    4
    0 Votes
    4 Posts
    2k Views
    Pradeep KumarP
    hi, @LuAria , wat ws the value coming in Numtwo ?. Nways ur got solution. Happy coding. Thanks,