Updated for the type-less version
Getty Ritter
9 years ago
| 51 | 51 |
exec db "END TRANSACTION;"
|
| 52 | 52 |
return result
|
| 53 | 53 |
|
| 54 | |
withSQLiteDb :: FilePath -> (TansuDb k v -> IO a) -> IO a
|
| 54 |
withSQLiteDb :: FilePath -> (TansuDb -> IO a) -> IO a
|
| 55 | 55 |
withSQLiteDb path mote = do
|
| 56 | 56 |
exists <- doesFileExist path
|
| 57 | 57 |
conn <- open (T.pack path)
|
| 1 |
{-# LANGUAGE OverloadedStrings #-}
|
| 2 |
|
| 1 | 3 |
module Main where
|
| 2 | 4 |
|
| 3 | 5 |
import Control.Monad (void)
|
|
| 16 | 18 |
putStr "looking up key 'three': "
|
| 17 | 19 |
rs <- run db $ get "three"
|
| 18 | 20 |
case rs of
|
| 19 | |
Right val -> putStrLn val
|
| 21 |
Right val -> print val
|
| 20 | 22 |
Left _ -> putStrLn "...not in the database."
|
| 21 | 23 |
|
| 22 | 24 |
putStr "looking up key 'five': "
|
| 23 | 25 |
rs <- run db $ get "five"
|
| 24 | 26 |
case rs of
|
| 25 | |
Right val -> putStrLn val
|
| 27 |
Right val -> print val
|
| 26 | 28 |
Left _ -> putStrLn "...not in the database."
|
| 11 | 11 |
build-type: Simple
|
| 12 | 12 |
cabal-version: >=1.10
|
| 13 | 13 |
|
| 14 |
flag build-example
|
| 15 |
description: Build Example application
|
| 16 |
default: False
|
| 17 |
|
| 14 | 18 |
library
|
| 15 | 19 |
exposed-modules: Database.Tansu.Backend.SQLite3
|
| 16 | 20 |
build-depends: base >=4.8 && <4.9,
|
|
| 22 | 26 |
default-language: Haskell2010
|
| 23 | 27 |
|
| 24 | 28 |
executable sample
|
| 29 |
if !flag(build-example)
|
| 30 |
buildable: False
|
| 25 | 31 |
main-is: Main.hs
|
| 26 | 32 |
build-depends: base, tansu, tansu-sqlite3
|
| 27 | 33 |
hs-source-dirs: sample
|