import Database.HDBC.Sqlite3 import Database.HDBC import System.Environment main :: IO() main = do query 3400 query :: Int -> IO () query id = do conn <- connectSqlite3 "library.db" r <- quickQuery' conn "SELECT id, name from contributors where id = ? ORDER BY id" [toSql id] -- Convert each row into a String let stringRows = map convRow r -- Print the rows out mapM_ putStrLn stringRows -- And disconnect from the database disconnect conn where convRow :: [SqlValue] -> String convRow [sqlid, sqlname] = show id ++ ": " ++ name where id = (fromSql sqlid)::Integer name = case fromSql sqlname of Just x -> x Nothing -> "NULL" convRow x = fail $ "Unexpected result: " ++ show x
main = do args <- getArgs query (read (args!!1) :: Int)
arg1 <- getArgs query (read $ head arg1)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)