Skip to content

Instantly share code, notes, and snippets.

@kindaro
Last active January 8, 2021 19:47
Show Gist options
  • Save kindaro/9abcc4b737099a53fb7d4160d0ca8952 to your computer and use it in GitHub Desktop.
Save kindaro/9abcc4b737099a53fb7d4160d0ca8952 to your computer and use it in GitHub Desktop.
cabal-version: 2.2
name: fake-package
version: 0
executable script
main-is: Main.hs
other-modules:
Templates
LocalQ
default-language: Haskell2010
default-extensions: TemplateHaskell, TypeSynonymInstances, MultiParamTypeClasses, ScopedTypeVariables, FlexibleInstances, OverloadedStrings
ghc-options: -ddump-splices -ddump-to-file
build-depends:
base,
opaleye,
template-haskell,
pretty-show,
postgresql-simple,
mtl, transformers
, product-profunctors
module Main where
import Data.Foldable
import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple.FromField
import qualified Opaleye
import Templates
makeOpaleyeInterface
TableIdentifier {maybeNameOfSchema = Just "information_schema", nameOfTable = "columns"}
[ ColumnDescription {nameOfColumn = "table_schema", typeOfColumn = ''Opaleye.PGText, haskellType = ''String}
, ColumnDescription {nameOfColumn = "table_name", typeOfColumn = ''Opaleye.PGText, haskellType = ''String}
, ColumnDescription {nameOfColumn = "column_name", typeOfColumn = ''Opaleye.PGText, haskellType = ''String}
, ColumnDescription {nameOfColumn = "data_type", typeOfColumn = ''Opaleye.PGText, haskellType = ''String}
]
main :: IO ( )
main = do
connection <- connectPostgreSQL "host=localhost dbname=example"
columns :: [Haskell__'information_schema__columns'] <-
runSelect__'information_schema__columns' connection
traverse_ print columns
@kindaro
Copy link
Author

kindaro commented Jan 6, 2021

Example for Opaleye Templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment