haskell - 带有 HDBC 的 Haskell SQLError
问题描述
我想读取一个包含多行的文件并将它们保存在我的表中。一切都很好,但是当它到达我第一行的最后一个元素时,它会以 SqlError 停止。
readLines :: FilePath -> IO ()
readLines n =
do s <- readFile n
mapM_ (\x -> insertbdd x $ lines s !! 1) [3..9]
insertbdd :: Int -> String -> IO ()
insertbdd _ [] = putStrLn "k" -- pattern matching that doesn't work
insertbdd ng xs =
do conn <- connectSqlite3 "ngram.db"
stmt <- handleSqlError $ prepare conn "insert into n3 (seq) values (?)"
execute stmt $ take 1 $ (map toSql) $ ngrams ng xs
commit conn
insertbdd ng (tail xs)
ngrams :: Int -> [a] -> [[a]]
ngrams n l = take (length l - (n - 1)) . map (take n) . tails $ l
停止与此消息
*** Exception: SqlError {seState = "", seNativeError = -1, seErrorMsg = "In HDBC execute, received [] but expected 1 args."}
我写了很多不匹配的模式。
知道为什么会这样吗?
解决方案
推荐阅读
- c# - 添加查询以具有使用 datediff 函数的条件
- javascript - 您如何区分 Mac 和 Windows 键盘键,例如“Control”?
- html - 将动态内容子项垂直对齐到中间,但在整行中共享相同的“中间基线”
- javascript - 尝试根据昵称/显示名称获取成员。Discord.js BOT
- python - 无法安装和运行 python 应用程序 MacOS
- pandas - 如何在熊猫数据框上应用 api
- vbscript - 经典 ASP:无法从函数返回 False,我收到类型不匹配错误
- javascript - Gatsby graphql 查询带有空数组的 json 数据会引发错误
- css - 找不到类型为“text/css”的文件“owl.theme”,Rails 6
- java - 选择排序:存储值而不是索引