Here is the info on the ErrorMisuse error:
https://www.sqlite.org/cvstrac/wiki?p=LibraryRoutineCalledOutOfSequence
Perhaps the connection has already been closed? Or are you using the same connection in two different threads?
Here is some sample code which works:
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import qualified Data.Text as T
import Database.SQLite.Simple
import Database.SQLite.Simple.FromRow
dumpTable conn table = do
r <- query_ conn "SELECT * from test" :: IO [(Int,String,Int)]
mapM_ print r
main :: IO ()
main = do
conn <- open "test.db"
execute_ conn "CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, firstname TEXT, pets INTEGER)"
execute conn "INSERT INTO test (firstname, pets) VALUES (?,?)"
("Alice" :: String, 2 :: Int)
execute conn "INSERT INTO test (firstname, pets) VALUES (?,?)"
("Bob" :: String, 3 :: Int)
putStrLn "before:"
dumpTable conn "test"
execute conn "UPDATE TEST SET pets = pets + ?" (Only (4 :: Int))
putStrLn "after:"
dumpTable conn "test"
close conn