Flake & cabal setup

This commit is contained in:
Paul Brinkmeier
2025-07-15 18:50:56 +02:00
commit fda4e7530c
11 changed files with 324 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
{-# 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"
+13
View File
@@ -0,0 +1,13 @@
{-# LANGUAGE OverloadedStrings #-}
module Yore.Repl (connect, exec) where
import qualified Database.PostgreSQL.LibPQ as LibPQ
import Database.PostgreSQL.LibPQ (Connection)
connect :: IO Connection
connect = LibPQ.connectdb "host=localhost"
exec :: (Connection -> IO a) -> IO a
exec f = f =<< connect