SQLite with foreign key constraints enabled?

SQLite with foreign key constraints enabled?

von Stephan Haller -
Anzahl Antworten: 1

Hi,

I want to write a question where students need to enter SQL statements that respect foreign key constraints set in the schema. E.g., you should not be allowed to delete an item that still has references to it.

SQLite doesn't apparently enforce foreign key constraints by default. In the command-line version, you first have to set PRAGMA foreign_keys = ON.

How can this pragma be changed with moodle coderunner? Is there a way to insert the code before the student code is executed in the test? Or are there some configuration changes necessary when connecting CodeRunner to SQLite?

Sorry if this is a newbie question, but I'd appreciate any help.

-Stephan

Als Antwort auf Stephan Haller

Re: SQLite with foreign key constraints enabled?

von Stephan Haller -
Just found the answer myself...

The field "Extra template data" can be used to enter this. PRAGMA