import * as postgres from "https://deno.land/x/postgres@v0.16.1/mod.ts"; import { type QueryArguments } from "https://deno.land/x/postgres@v0.16.1/query/query.ts?s=QueryArguments"; export { type QueryObjectResult } from "https://deno.land/x/postgres@v0.16.1/query/query.ts?s=QueryArguments"; const databaseUrl = Deno.env.get("DATABASE_URL") || "postgresql://danielflanagan:@127.0.0.1:5432/lyricscreen"; const pool = new postgres.Pool(databaseUrl, 3, true); export async function query(sql: string, ...args: QueryArguments[]) { let result = null; try { const connection = await pool.connect(); try { result = await connection.queryObject(sql, ...args); } catch (err) { console.error("Error querying database:", err); } finally { connection.release(); } } catch (err) { console.error("Error connecting to database:", err); } return result; }