File: Main.hs

package info (click to toggle)
haskell-hsql 1.4-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 656 kB
  • ctags: 43
  • sloc: sh: 2,723; makefile: 192; haskell: 174; ansic: 37
file content (34 lines) | stat: -rwxr-xr-x 889 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Main where

import Control.Exception
import Database.HSQL.ODBC
import Queries

-- Change the following definitions to connect to
-- another data source
datasource = "HSQL_Example"
user_id    = ""
password   = ""

main = handleSql print $ do
	bracket (connect datasource user_id password) disconnect $ \c ->
		inTransaction c $ \c -> do
			createTables c
			insertRecords c
			retrieveRecords c
			rs <- retrieveRecords c
			
			putStrLn " Records inserted in table Test are: "
			putStrLn "*************************************"
			mapM print rs
			putStrLn "*************************************"
			putStrLn ""
			
			putStrLn " The tables in your database are:    "
			putStrLn "*************************************"
			mi <- getMetaInfo c
			mapM print mi
			putStrLn "*************************************"
			putStrLn ""
			
			dropTables c