我正在尝试执行以下操作,但在编译此源代码时不断遇到解析错误:
instance FromRow Job where
{-# DEPRECATED fromRow "Please do not depend on the FromRow instance of the Job type. It does not handle optional features, such as job-results and job-workflows. Depending upon your scenario, use 'jobRowParserSimple' or 'jobRowParserWithWorkflow' directly." #-}
fromRow = jobRowParserSimple
Haskell 可以做到这一点吗?怎么办?
{-# LANGUAGE OverloadedStrings #-}
import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple.FromRow
-- Define your Job type
data Job = Job { jobId :: Int, jobName :: String } deriving Show
-- Implement the FromRow instance
instance FromRow Job where
fromRow = Job <$> field <*> field
main :: IO ()
main = do
conn <- connectPostgreSQL "your_database_connection_string"
-- Replace the SQL query with your actual query to fetch Job records
jobs <- query_ conn "SELECT job_id, job_name FROM jobs" :: IO [Job]
mapM_ print jobs
close conn