mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-16 07:52:05 +03:00
21 lines
595 B
Haskell
21 lines
595 B
Haskell
|
|
module PgTestDataSource (
|
|
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 Database.HDBC.TH (ConName, 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
|