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