Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import Database.HDBC
import Database.HDBC.ODBC
data Person = Person
{ id :: Int
, name :: [Char] }
deriving Show
convRow :: [SqlValue] -> Person
convRow [sqlId, sqlDesc] =
Person intId desc
where intId = (fromSql sqlId) :: Int
desc = case fromSql sqlDesc of
Just x -> x
Nothing -> "NULL"
main =
let connectionString = "DSN=TestDB"
ioconn = connectODBC connectionString in
conn <- ioconn
vals <- quickQuery conn "SELECT TOP 10 * FROM Person;" []
let rows = map convRow vals
mapM_ print rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.