开发者

Haskell HDBC-Sqlite3 always returns SqlByteString values

开发者 https://www.devze.com 2023-02-14 23:05 出处:网络
I am using HDBC sqlite3 haskell driver to access local sqlite3 database which PRAGMA encoding is UTF-8 And as result, for example for

I am using HDBC sqlite3 haskell driver to access local sqlite3 database which

PRAGMA encoding

is

UTF-8

And as result, for example for

SELECT id, title FROM some_table

I'm always getting the result like this:

[[SqlByteString "1", SqlBy开发者_如何学编程teString "\210\129\123\211"], ... ]

That's weird! Yes, title contains 'national' symbols and yes, I'm sure that id has type of INTEGER.

So the questions are:

  1. Why 1 unicode symbol are threated as 2 ascii-like symbols?
  2. Why integer columns results bytestring values?


SQLite is an untyped database, so the fields in your database don't really have a type at all. You should be converting them to a more Haskellish value by using fromSql or safeFromSql from Database.HDBC.SqlValue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号