Guest User

Untitled

a guest
May 27th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import Database.HDBC
  2. import Database.HDBC.PostgreSQL
  3. import Data.List
  4.  
  5. type SQL = String
  6.  
  7. data Relation = Relation SQL
  8. deriving (Show)
  9.  
  10. sql (Relation sql) = sql
  11.  
  12. printTuples conn rel =
  13. quickQuery' conn ("SELECT DISTINCT * FROM " ++ (sql rel)) []
  14.  
  15. join rel1 rel2 =
  16. Relation ((sql rel1) ++ " NATURAL JOIN " ++ (sql rel2))
  17.  
  18. project fields rel1 =
  19. Relation ("(SELECT " ++ (intercalate "," fields) ++ " FROM " ++ (sql rel1) ++ ") a")
  20.  
  21. (π) = project
  22. (⋈) = join
Add Comment
Please, Sign In to add comment