Home » U++ Library support » U++ SQL » SQLite and foreign keys
Re: SQLite and foreign keys [message #40981 is a reply to message #40977] |
Thu, 17 October 2013 10:20 |
chickenk
Messages: 169 Registered: May 2007 Location: Grenoble, France
|
Experienced Member |
|
|
Another note: foreign keys in sqlite3 are deactivated by default.
To have them enabled by default, one should define the CPP macro SQLITE_DEFAULT_FOREIGN_KEYS, see line 112284 of uppsrc/plugin/sqlite3/lib/sqlite3.c.
I use sqlite3 at work outside of U++, and my own solution is the following code (because I use a precompiled sqlite3 library), but I suppose defining SQLITE_DEFAULT_FOREIGN_KEYS is equivalent:
int fkey_support;
int sqlRet = sqlite3_open(path, &DB);
/* [...] */
if (sqlite3_db_config(DB, SQLITE_DBCONFIG_ENABLE_FKEY, 1, &fkey_support) != SQLITE_OK)
{
/* handle error */
}
printf("Foreign keys support is %s.\n", fkey_support?"ON":"OFF");
|
|
|
Goto Forum:
Current Time: Sat May 11 15:33:18 CEST 2024
Total time taken to generate the page: 0.02429 seconds
|