Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 36 lines (28 sloc) 1.098 kB
5ef825c @waterson Initial revision.
waterson authored
1 module Main where
2
3 import Control.Monad
4 import Database.HDBC
5 import Database.HDBC.MySQL
6
06ba006 @waterson expose Connection type.
waterson authored
7 connectDatabase :: IO Connection
8 connectDatabase = connectMySQL defaultMySQLConnectInfo
9 { mysqlHost = "putterwell"
10 }
11
9382990 @waterson use a record type to handle the bevvy of mysql connection paramaters;…
waterson authored
12 go :: IO ()
06ba006 @waterson expose Connection type.
waterson authored
13 go = do conn <- connectDatabase
9382990 @waterson use a record type to handle the bevvy of mysql connection paramaters;…
waterson authored
14
1853a82 @waterson more testing
waterson authored
15 putStrLn $ "driver " ++ (show $ hdbcDriverName conn)
16 putStrLn $ "server version " ++ (show $ dbServerVer conn)
17 tables <- getTables conn
18 forM_ tables $ \t -> do
19 putStrLn $ "table " ++ t
20 cols <- describeTable conn t
21 forM_ cols $ \(name, desc) ->
22 putStrLn $ name ++ " " ++ (show desc)
23 rows0 <- quickQuery' conn "SELECT a FROM album" []
24 rows1 <- quickQuery' conn "SELECT str FROM album" []
25 forM_ (zip rows0 rows1) $ \(a, str) -> putStrLn $ "a=" ++ (show a) ++ ", str=" ++ (show str)
9382990 @waterson use a record type to handle the bevvy of mysql connection paramaters;…
waterson authored
26
eb6ff9e @waterson fix incorrect use of 'with' to allocate storage that is used for binds.
waterson authored
27 {-
4aa3a97 @waterson use Foreign.Concurrent to correctly incorporate Haskell finalizer for…
waterson authored
28 stmt <- prepare conn "INSERT INTO album VALUES (?, ?)"
29 n <- execute stmt [SqlWord32 3000000000, SqlString "hello"]
30 commit conn
eb6ff9e @waterson fix incorrect use of 'with' to allocate storage that is used for binds.
waterson authored
31 -}
32
4aa3a97 @waterson use Foreign.Concurrent to correctly incorporate Haskell finalizer for…
waterson authored
33
9382990 @waterson use a record type to handle the bevvy of mysql connection paramaters;…
waterson authored
34 main :: IO ()
4aa3a97 @waterson use Foreign.Concurrent to correctly incorporate Haskell finalizer for…
waterson authored
35 main = handleSqlError (replicateM_ 1 go)
Something went wrong with that request. Please try again.