This commit is contained in:
Cadyrov 2022-10-14 01:03:21 +10:00
parent 5f7b067d15
commit 5ff2f09a62

View File

@ -1,18 +1,70 @@
console.log('huynya');
console.log(4+9);
let switchBackground = 0;
// 16777215
// while (true) {
// document.querySelector('.main-wrapper').style.backgroundColor='#'+switchBackground.toString(16);
// switchBackground+=100;
// console.log(switchBackground)
// if (switchBackground >=16777215) { switchBackground = 0 }
// console.log(document.querySelector('.main-wrapper').style.backgroundColor)
// setTimeout(
// () => {
// console.log(document.querySelector('.main-wrapper').style.backgroundColor)
// },
// 3000
// );
console.log('wrok');
const pg = require('pg');
// }
const config = {
host: '77.34.74.77',
// Do not hard code your username and password.
// Consider using Node environment variables.
user: 'postgres',
password: 'postgres',
database: 'postgres',
port: 5432,
ssl: false
};
const client = new pg.Client(config);
client.connect
(
err =>
{
if (err) throw err;
else
{
addToDvachDatabase();
queryDatabase();
}
}
);
function addToDvachDatabase() { //Добавляем значение в базу данных dvach
console.log(`Running query to PostgreSQL server: ${config.host}`);
const query = "INSERT INTO dvach (post) VALUES ('Привет двач');";
client.query(query)
.then(res => {
//const rows = res.rows;
//rows.map(row => {
//console.log(`Прочитано следующее : ${JSON.stringify(row)}`);
// });
//process.exit();
})
.catch(err => {
console.log(err);
});
}
function queryDatabase() { //VSE ZNACHENIYA IZ BAZI DANNYKH
console.log(`Running query to PostgreSQL server: ${config.host}`);
const query = 'SELECT * FROM dvach;';
client.query(query)
.then(res => {
const rows = res.rows;
rows.map(row => {
console.log(`Прочитано следующее : ${JSON.stringify(row)}`);
});
process.exit();
})
.catch(err => {
console.log(err);
});
}