-
Notifications
You must be signed in to change notification settings - Fork 0
/
rnd.js
38 lines (34 loc) · 1.03 KB
/
rnd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { Client } = require('pg')
let loads = {
host: 'localhost',
port: 5432,
user: 'postgres',
password: 'jesh',
database:'school'
};
async function executeQuerry(sql){
var res;
const client = new Client(loads);
client.connect();
await client.query(sql).then(result => res = result.rows)
.catch(e => console.error(e.stack))
.then(() => client.end());
return res;
};
async function exe(){
// var sql = "CREATE TAB LE ORDER(ID INT,TITLE TEXT);";
// console.log("connected");
// client.query(sql, (err, res) => {
// if (err) {
// console.log(err.stack)
// } else {
// console.log(res.rows[0])
// }
// })
// await executeQuerry("INSERT INTO sample(ID) VALUES(4);");
await executeQuerry("CREATE TABLE IF NOT EXISTS ORDERS(ID INTEGER,TITLE TEXT,MESSAGE TEXT,QUANTITY TEXT,CITY TEXT,PRIMARY KEY(ID));")
// var sql = "SELECT * FROM ORDERS;";
// var result = await executeQuerry(sql);
//console.log(result);
}
exe();