46 lines
905 B
TypeScript
46 lines
905 B
TypeScript
import pkg from "pg";
|
|
const { Client } = pkg;
|
|
|
|
const v1client = new Client({
|
|
host: "localhost",
|
|
port: 5432,
|
|
user: "postgres",
|
|
password: "obelix",
|
|
database: "lst",
|
|
});
|
|
|
|
const v2client = new Client({
|
|
host: "localhost",
|
|
port: 5432,
|
|
user: "postgres",
|
|
password: "obelix",
|
|
database: "lst_db",
|
|
});
|
|
|
|
export const v1QueryRun= async (query:string)=> {
|
|
try {
|
|
await v1client.connect();
|
|
|
|
const res = await v1client.query(query);
|
|
|
|
console.log("Rows affected:", res.rowCount);
|
|
} catch (err) {
|
|
console.error("Error running query:", err);
|
|
} finally {
|
|
await v1client.end();
|
|
}
|
|
}
|
|
|
|
export const v2QueryRun = async (query:string)=> {
|
|
try {
|
|
await v2client.connect();
|
|
|
|
const res = await v2client.query(query);
|
|
|
|
console.log("Rows affected:", res.rowCount);
|
|
} catch (err) {
|
|
console.error("Error running query:", err);
|
|
} finally {
|
|
await v2client.end();
|
|
}
|
|
} |