mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-15 14:53:28 +03:00
18 lines
518 B
Haskell
18 lines
518 B
Haskell
|
|
module PgTestDataSource (
|
|
defineTable
|
|
) where
|
|
|
|
import Language.Haskell.TH (Q, Dec, runIO)
|
|
import Database.HDBC.PostgreSQL (connectPostgreSQL, Connection)
|
|
import Database.HDBC.Schema.PostgreSQL (driverPostgreSQL)
|
|
import Database.HDBC.TH (ConName, pprQ, defineTableFromDB)
|
|
|
|
connect :: IO Connection
|
|
connect = connectPostgreSQL "dbname=testdb"
|
|
|
|
defineTable :: String -> String -> [ConName] -> Q [Dec]
|
|
defineTable scm tbl derives = do
|
|
conn <- runIO connect
|
|
defineTableFromDB driverPostgreSQL conn scm tbl derives
|