
Hello all, while working through `Real World Haskell' Chapter 21 I hit the following problem: Using sqlite3, enabling foreign keys with "PRAGMA foreign_keys = ON;" must be done outside a transaction. However, HDBC doesn't seem to provide a possibility to submit such a statement to the database outside of a transaction. The only workaround I've found looks like this:
openDatabase :: String -> IO Connection openDatabase name = do conn <- connectSqlite3 name run conn "COMMIT;" [] -- manually close HDBC's underlyingTX run conn "PRAGMA foreign_keys = ON;" [] -- execute outside of TX run conn "BEGIN;" [] -- open a new TX for HDBC again prepareDatabase conn return conn
Am I missing something in HDBC's API or is this the only way to do it? Many thanks in advance, Pete.