[Haskell-beginners] Sqlite3 pragma statements

Paul Higham polygame at mac.com
Sun Apr 28 18:02:27 CEST 2013


I am using sqlite3 as a backend database for an application that I am writing in Haskell.  In the database schema there are a number of foreign key constraints but sqlite3 has the referential integrity constraint checking turned off by default.  To turn on the constraint checking one needs to have issued the following command

	pragma foreign_keys = ON;

for every connection to the database.  This works if done directly in the sqlite3 shell, but I want to do in from Haskell code.  The obvious thing to try would be

	runRaw conn "pragma foreign_keys = on"

and this does in fact run with no errors.  However the constraint checking does not appear to be happening since I can subsequently add rows to a table that violate the foreign key constraint.

I have found no documented way to issue pragma commands in either Database.HDBC or Database.HDBC.Sqlite3, nor has a google search turned up anything that works.

Does anyone have any ideas?

Thanx!

:: paul


More information about the Beginners mailing list