import pg from 'pg'

const { Pool } = pg

export const forecastPool = process.env.FORECAST_DATABASE_URL
  ? new Pool({ connectionString: process.env.FORECAST_DATABASE_URL })
  : null

export async function queryForecast(sql, params) {
  if (!forecastPool) throw new Error('FORECAST_DATABASE_URL not configured')
  const res = await forecastPool.query(sql, params)
  return res.rows
}
