9module Main (main) where
11import Control.Category ((>>>))
12import Control.Monad.Base
13import Data.Function ((&))
17import Squeel.PostgreSQL
19import qualified Data.ByteString.Char8 as Char8
23 Char8.putStrLn "squeel"
24 connectionString <- pure
25 "host=localhost port=5432 dbname=exampledb"
26 Char8.putStrLn $ "connecting to " <> connectionString
27 connection0 <- connectdb connectionString
28 Char8.putStrLn "creating tables"
29 connection1 <- flip execPQ connection0 $ pqExec $
31 ( (text & notNull) `As` #name
35 ( (int4 & notNull) `As` #col1
36 :* (int4 & notNull) `As` #col2
38 connection2 <- flip execPQ connection1 $ do
39 _insertTable1Result <- pqExec $
40 insertInto #table1 ( 1 `As` #col1 :* 2 `As` #col2 :* Nil )
42 insertInto #table1 ( 3 `As` #col1 :* 4 `As` #col2 :* Nil )
43 Just selectTable1Result <- flip pqExecParams Nil $
44 (select $ starFrom #table1 :: Statement '[] Columns Tables Tables)
45 Just (Right value00) <- getvalue selectTable1Result (RowNumber 0) colNum0
46 Just (Right value01) <- getvalue selectTable1Result (RowNumber 0) colNum1
47 Just (Right value10) <- getvalue selectTable1Result (RowNumber 1) colNum0
48 Just (Right value11) <- getvalue selectTable1Result (RowNumber 1) colNum1
50 print (value00 :: Int32)
51 print (value01 :: Int32)
52 print (value10 :: Int32)
53 print (value11 :: Int32)
57 '[ "col1" ::: 'Required ('NotNull 'PGInt4)
58 , "col2" ::: 'Required ('NotNull 'PGInt4)
60-- type SumAndCol1 = '[ "sum" ::: 'NotNull 'PGInt4, "col1" ::: 'NotNull 'PGInt4]
61type StudentsColumns = '["name" ::: 'Required ('NotNull 'PGText)]
62type Tables = '[ "table1" ::: Columns, "students" ::: StudentsColumns]
64-- [ "orderID" ::: 'NotNull 'PGInt4
65-- , "orderVal" ::: 'NotNull 'PGText
66-- , "customerID" ::: 'NotNull 'PGInt4
67-- , "shipperID" ::: 'NotNull 'PGInt4
69-- type CustomerColumns =
70-- [ "customerID" ::: 'NotNull 'PGInt4, "customerVal" ::: 'NotNull 'PGFloat4 ]
71-- type ShipperColumns =
72-- [ "shipperID" ::: 'NotNull 'PGInt4, "shipperVal" ::: 'NotNull 'PGBool ]
74-- [ "shippers" ::: ShipperColumns
75-- , "customers" ::: CustomerColumns
76-- , "orders" ::: OrderColumns
79-- [ "orderVal" ::: 'NotNull 'PGText
80-- , "customerVal" ::: 'NotNull 'PGFloat4
81-- , "shipperVal" ::: 'NotNull 'PGBool
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list