Den tis 16 mars 2021 kl 21:21 skrev Elvis Stansvik <elvst...@gmail.com>:
>
> Den tis 16 mars 2021 kl 20:19 skrev Jérôme Godbout <godbo...@amotus.ca>:
> >
> > 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”);
>
> You can't use a bound parameter value for the table name. This would
> be the case even if you used the SQLite C library. I imagine this is
> the case in other database engines as well.

Some good answers here:
https://stackoverflow.com/questions/11312737/can-i-parameterize-the-table-name-in-a-prepared-statement

Elvis

>
> Elvis
>
> >
> >
> > 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,
> >
> > _______________________________________________
> > Interest mailing list
> > Interest@qt-project.org
> > https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to