import mysql from "mysql2/promise";
import { drizzle } from "drizzle-orm/mysql2";
import { env } from "@/env";

// Create a singleton connection pool for the ZXDB database
const pool = mysql.createPool({
  uri: env.ZXDB_URL,
  connectionLimit: 10,
  // Larger queries may be needed for ZXDB
  maxPreparedStatements: 256,
});

export const db = drizzle(pool);

export type Db = typeof db;
