Enable FK on SQLite engine

Forum for posting problems using QxOrm library

Enable FK on SQLite engine

Postby gianks » Tue Sep 13, 2016 1:12 pm

Hi all,
testing my application i've found inconsistent values sometimes in FK columns, probably after wrong ops my side.

Looking on sqlite website seems that by default is necessary since a certain release to manualy enable the PRAGMA at the startup of the application to enforce the FK (uniqueness is already enforced in any case).
How can i do that through QxOrm when i initialize the singleton instance?

See here: http://www.sqlite.org/pragma.html#pragma_foreign_keys

Thanks
Best Regards
Gianluca
gianks
 
Posts: 45
Joined: Mon Jul 04, 2016 1:04 pm

Re: Enable FK on SQLite engine

Postby qxorm » Tue Sep 13, 2016 1:44 pm

Hello,

You can use the qx::dao::call_query() function to execute a custom SQL query : https://www.qxorm.com/qxorm_en/manual.html#manual_3610

For example :
Code: Select all
QString sql = "PRAGMA foreign_keys;";
qx_query query(sql);
QSqlError err = qx::dao::call_query(query);
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 4 guests

cron