[Haskell-beginners] HDBC - outside a transaction
pnovotnik at googlemail.com
Tue Mar 8 08:54:44 CET 2011
while working through `Real World Haskell' Chapter 21 I hit the
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,
More information about the Beginners