22 lines
505 B
Haskell
22 lines
505 B
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Yore.DB
|
|
( Table (..)
|
|
, getTables
|
|
) where
|
|
|
|
import Database.PostgreSQL.LibPQ (Connection)
|
|
import GHC.Generics (Generic)
|
|
|
|
import qualified Database.PostgreSQL.Opium as Opium
|
|
|
|
data Table = Table
|
|
{ schema :: String
|
|
, name :: String
|
|
} deriving (Show, Generic)
|
|
|
|
instance Opium.FromRow Table
|
|
|
|
getTables :: Connection -> IO (Either Opium.Error [Table])
|
|
getTables = Opium.fetch_ "SELECT table_schema AS schema, table_name AS name FROM information_schema.tables"
|