Last active
January 8, 2021 19:47
-
-
Save kindaro/9abcc4b737099a53fb7d4160d0ca8952 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example for Opaleye Templates.