1{-# LANGUAGE OverloadedStrings #-}
2import ProjectM36.Client
3import ProjectM36.TupleSet
6import ProjectM36.Relation.Show.Term
10 -- 1. create a ConnectionInfo
11 let connInfo = RemoteProcessConnectionInfo "mytestdb" (createNodeId "127.0.0.1" defaultServerPort)
12 -- 2. conncted to the remote database
13 eConn <- connectProjectM36 connInfo
15 Left err -> putStrLn (show err)
17 --3. create a session on the "master" branch
18 eSessionId <- createSessionAtHead "master" conn
20 Left err -> putStrLn (show err)
22 --4. define a new relation variable with a DatabaseContext expression
23 let attrs = attributesFromList [Attribute "name" stringAtomType, Attribute "age" intAtomType]
24 mErr1 <- executeDatabaseContextExpr sessionId conn (Define "person" attrs)
26 --5. add a tuple to the relation referenced by the relation variable
27 let (Right tupSet) = mkTupleSetFromList attrs [[stringAtom "Bob", intAtom 45]]
28 mErr2 <- executeDatabaseContextExpr sessionId conn (Insert "person" (MakeStaticRelation attrs tupSet))
31 --6. execute a relational algebra query
32 let restrictionPredicate = AttributeEqualityPredicate "name" (NakedAtomExpr (stringAtom "Steve"))
33 eRel <- executeRelationalExpr sessionId conn (Restrict restrictionPredicate (RelationVariable "person"))
35 Left err -> putStrLn (show err)
36 Right rel -> putStrLn (show $ showRelation rel)
38 --7. close the connection
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