hdbc / hdbc-sqlite3

Sqlite v3 driver for HDBC
BSD 3-Clause "New" or "Revised" License
21 stars 6 forks source link

"PRAGMA synchronous = OFF" throws error #6

Closed richsmith92 closed 12 years ago

richsmith92 commented 13 years ago

When trying to run this code:

main = do conn <- connectSqlite3 "test.db" runRaw conn "PRAGMA synchronous = OFF"

I get this output:

TestDB.hs: SqlError {seState = "", seNativeError = 1, seErrorMsg = "prepare 25: PRAGMA synchronous = OFF: Safety level may not be changed inside a transaction"}

If I use the pragma in the autocommit sqlite3 console, all works right.

jgoerzen commented 13 years ago

You could probably wrap it in "COMMIT; PRAGMA synchronous = OFF; BEGIN TRANSACTION"

richsmith92 commented 13 years ago

Thanks. I have already switched to low-level "sqlite" package. But I'll try your solution if there will be opportunity. You can close the issue if you don't plan to add special functions for SQLite pragmas.

bartoszw commented 12 years ago

I'm also blocked with similar problem. Thererfore: Does it make sense to put pragmas feature only while connecting to DB? I think that foreign_keys enabling yes, but I'm not sure if this is generally proper solution. Alternative solution would require change of API (IConnection type class would need one more function) - IMHO. If this is true the first solution would be lightweight in comparison.

bartoszw commented 12 years ago

For the same reason like described in the ticket I was not able to run "PRAGMA foreign_keys = ON". The solution https://github.com/hdbc/hdbc-sqlite3/issues/6#issuecomment-1184186 solves my problem though, so my previous comment https://github.com/hdbc/hdbc-sqlite3/issues/6#issuecomment-3050835 can be forgotten.