const { Pool } = require("pg");
const pool = new Pool({
  user: "postgres",
  password: "Sethuds@12",
  host: "localhost",
  port: 5432,
  database: "textile"
});

async function main() {
  try {
    console.log("Running total count query...");
    const resCount = await pool.query("SELECT COUNT(*) FROM customer_master");
    console.log("Total Count:", resCount.rows[0]);

    console.log("Running select query...");
    const resData = await pool.query(`
      SELECT cus_id, customer_name, mobile1, mobile2, email, gst_no
      FROM customer_master
      ORDER BY customer_name LIMIT 10 OFFSET 0
    `);
    console.log("Returned Rows:", resData.rows.length);
    console.log("Rows data:", resData.rows);
  } catch (err) {
    console.error("DB Query Error:", err);
  } finally {
    await pool.end();
  }
}

main();
