yore/src/Yore/DB.hs
2025-07-15 18:50:56 +02:00

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"