Re: [Interest] QSqlQuery bind value

2021-03-17 Thread Jérôme Godbout
Oh, great, thanks for the pointer, will do, good to known.


On Mar 16, 2021, at 5:48 PM, Elvis Stansvik 
mailto:elvst...@gmail.com>> wrote:

Yea, you can always use db.driver()->escapeIdentifier(x,
QSqlDriver::TableName) if you want to sleep a little better anyway.

Elvis


Den tis 16 mars 2021 kl 21:52 skrev Jérôme Godbout 
mailto:godbo...@amotus.ca>>:

Thanks, that was the problems, this is annoying, but I do create the query 
prepare with a String with arg (I known this is bad, but the tablename is 
provided by inner code only, this is not user inputs of any sort).

On Mar 16, 2021, at 4:23 PM, Elvis Stansvik 
mailto:elvst...@gmail.com>> wrote:

Den tis 16 mars 2021 kl 21:21 skrev Elvis Stansvik 
mailto:elvst...@gmail.com>>:


Den tis 16 mars 2021 kl 20:19 skrev Jérôme Godbout 
mailto: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


Jerome Godbout
Software/Firmare Lead Amotus

C: (581) 777-0050
O: (418) 800-1073 ext.: 114
godbo...@amotus.ca



dimonoff.com   |amotus.ca

We have moved!
1015 Avenue Wilfrid-Pelletier, Québec, QC G1W 0C4, 4e étage


Jerome Godbout
Software/Firmare Lead Amotus

C: (581) 777-0050
O: (418) 800-1073 ext.: 114
godbo...@amotus.ca

[cid:image007.png@01D70B66.39FB01C0]

dimonoff.com   |amotus.ca

We have moved!
1015 Avenue Wilfrid-Pelletier, Québec, QC G1W 0C4, 4e étage

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QSqlQuery bind value

2021-03-16 Thread Elvis Stansvik
Yea, you can always use db.driver()->escapeIdentifier(x,
QSqlDriver::TableName) if you want to sleep a little better anyway.

Elvis


Den tis 16 mars 2021 kl 21:52 skrev Jérôme Godbout :
>
> Thanks, that was the problems, this is annoying, but I do create the query 
> prepare with a String with arg (I known this is bad, but the tablename is 
> provided by inner code only, this is not user inputs of any sort).
>
> On Mar 16, 2021, at 4:23 PM, Elvis Stansvik  wrote:
>
> Den tis 16 mars 2021 kl 21:21 skrev Elvis Stansvik :
>
>
> Den tis 16 mars 2021 kl 20:19 skrev Jérôme Godbout :
>
>
> 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
>
>
> Jerome Godbout
> Software/Firmare Lead Amotus
>
> C: (581) 777-0050
> O: (418) 800-1073 ext.: 114
> godbo...@amotus.ca
>
>
>
> dimonoff.com   |amotus.ca
>
> We have moved!
> 1015 Avenue Wilfrid-Pelletier, Québec, QC G1W 0C4, 4e étage
>
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QSqlQuery bind value

2021-03-16 Thread Jérôme Godbout
Thanks, that was the problems, this is annoying, but I do create the query 
prepare with a String with arg (I known this is bad, but the tablename is 
provided by inner code only, this is not user inputs of any sort).

On Mar 16, 2021, at 4:23 PM, Elvis Stansvik 
mailto:elvst...@gmail.com>> wrote:

Den tis 16 mars 2021 kl 21:21 skrev Elvis Stansvik 
mailto:elvst...@gmail.com>>:

Den tis 16 mars 2021 kl 20:19 skrev Jérôme Godbout 
mailto: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

Jerome Godbout
Software/Firmare Lead Amotus

C: (581) 777-0050
O: (418) 800-1073 ext.: 114
godbo...@amotus.ca

[cid:image007.png@01D70B66.39FB01C0]

dimonoff.com   |amotus.ca

We have moved!
1015 Avenue Wilfrid-Pelletier, Québec, QC G1W 0C4, 4e étage

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QSqlQuery bind value

2021-03-16 Thread Elvis Stansvik
Den tis 16 mars 2021 kl 21:21 skrev Elvis Stansvik :
>
> Den tis 16 mars 2021 kl 20:19 skrev Jérôme Godbout :
> >
> > 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


Re: [Interest] QSqlQuery bind value

2021-03-16 Thread Elvis Stansvik
Den tis 16 mars 2021 kl 20:19 skrev Jérôme Godbout :
>
> 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.

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