haskell-relational-record/relational-join-HDBC-pgTest/pgTest/PgTestDataSource.hs

22 lines
647 B
Haskell
Raw Normal View History

module PgTestDataSource (
2013-05-10 21:31:43 +04:00
connect, defineTable
) where
import Language.Haskell.TH (Q, Dec, TypeQ)
import Database.HDBC.PostgreSQL (connectPostgreSQL, Connection)
import Database.HDBC.Schema.PostgreSQL (driverPostgreSQL)
import Database.HDBC.Schema.Driver (typeMap)
import Language.Haskell.TH.Name.CamelCase (ConName)
2013-05-04 18:56:24 +04:00
import Database.HDBC.TH (defineTableFromDB)
connect :: IO Connection
connect = connectPostgreSQL "dbname=testdb"
defineTable :: [(String, TypeQ)] -> String -> String -> [ConName] -> Q [Dec]
defineTable tmap scm tbl derives = do
defineTableFromDB
connect
(driverPostgreSQL { typeMap = tmap })
scm tbl derives