[Interest] QSqlQuery bind value

Jérôme Godbout godboutj at amotus.ca
Tue Mar 16 20:17:22 CET 2021


Hi,

I’m trying to use the Sql with Sqlite with Qt. The database seem to be working just fine, but I run into troubles with the bind value. The named bind doesn’t seem to work (Qt 5.15.2, Mac OS):


m_sql->m_create_table(m_database);

m_sql->m_create_table.prepare(R"raw(CREATE TABLE IF NOT EXISTS :table name (idkey TEXT PRIMARY KEY, data TEXT) WITHOUT ROWID)raw”);


Note: I did try to add the ending ; it make no difference. Is it required? I do not see it in any example.

The prepare return false for some reason, I did try with quotes this solve the prepare but I thing the escaping should be done automatically?! Is the value escape character automatically for named and positional args? What is wrong with this query, the query work just fine into sqlite3.

CREATE TABLE IF NOT EXISTS ':tablename’ (idkey TEXT PRIMARY KEY, data TEXT) WITHOUT ROWID;


It doesn’t complain, but create a table name :table name instead! The replace doesn’t occur into the quote ‘ '


This query work just fine into sqlite command line.

CREATE TABLE IF NOT EXISTS toto (idkey TEXT PRIMARY KEY, data TEXT) WITHOUT ROWID;


What is wrong with this?! This seem to be just like the examples, is SQLite any special in that regards (I known only a single statement is required for sqlite).

Thanks,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210316/42d11db3/attachment-0001.html>


More information about the Interest mailing list