[Interest] QtSql database insertion issues...

BRM bm_witness at yahoo.com
Wed Apr 22 04:42:08 CEST 2015


I've been out of the Qt loop for a little bit; but I'm working to bring myself back up to speed.I'm presently working on a small project that is basically a GUI equivalent of md5sum/sha1sum where I'm attempting to store the data in a SQLite Database during run-time. I've already done a command-line version using python, and I'm pulling the SQL statements from there. However, I am having trouble with the QSqlQuery prepared statements. The entire code chunk is here:

https://github.com/BenjamenMeyer/qtmd5gui/blob/branch_qt4_base/src/hash_db.cpp
I'm building the project on Kubuntu 14.10, using the Qt4.8 libraries provided by the distro.

To summarize the code, I'm doing the following:
    QSqlQuery insertion(myDb);    insertion.prepare("INSERT INTO master_directory (hash, path) VALUES(:hash, :path)");    insertion.bindValue(":hash", "some hash");    insertion.bindValue(":path", "/some/path");    if (!insertion.exec()) qDebug() << "insertion failed. Log errors and value bindings";

I've added debug output that shows the values being bound; however, it continues to complain about a parameter mismatch.

You can see the output here:
https://gist.github.com/BenjamenMeyer/dffe01b702dc8f507c17

I've tried binding both by name (preferred) and by order. (I have a C Preprocessor Define to control it); but neither are working.

This is my first time really playing with a database via Qt.
What am I doing wrong?
TIA,
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150422/05d10808/attachment.html>


More information about the Interest mailing list