这里是关于ErrorMisuse错误信息:
https://www.sqlite.org/cvstrac/wiki?p=LibraryRoutineCalledOutOfSequence
也许连接已经关闭?或者你在两个不同的线程中使用相同的连接?
下面是一些示例代码的工作原理:
{-# 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
什么是错误讯息?它是编译器错误还是运行时错误? – ErikR
这是一个运行时错误:SQLite3在尝试执行准备时返回了ErrorMisuse“UPDATE测试SET v =?”:调用序列外的库例程 – Relu