Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joaomilho
Forked from softa/relational.hs
Created May 8, 2014 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaomilho/fcc3901eee540d609f78 to your computer and use it in GitHub Desktop.
Save joaomilho/fcc3901eee540d609f78 to your computer and use it in GitHub Desktop.
-- relational.hs
import Database.HDBC
import Database.HDBC.PostgreSQL
import Data.List
printTuples conn rel = quickQuery' conn ("SELECT DISTINCT * FROM " ++ rel) []
(⋈) = intercalate " NATURAL JOIN "
(π) fields rel1 = "(SELECT " ++ (intercalate "," fields) ++ " FROM " ++ rel1 ++ ") a"
-- no gchi
:m Database.HDBC Database.HDBC.PostgreSQL
:l relational.hs
let teste = π ["empno", "ename", "dname"] $ (⋈) ["emp", "dept"]
conn <- connectPostgreSQL "host=localhost dbname=hdbtest user=hdbtest"
printTuples conn teste
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment