Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const pg = require('pg');
- const config = {
- host: 'serverzpi.postgres.database.azure.com',
- // Do not hard code your username and password.
- // Consider using Node environment variables.
- user: 'ZpiAdmin@serverzpi',
- password: 'Zpi?kam1lNOWAK',
- database: 'savingapp',
- port: 5432,
- ssl: true
- };
- const client = new pg.Client(config);
- client.connect(err => {
- if (err){
- console.log(err)
- }
- else {
- queryDb();
- }
- });
- function queryDb(){
- console.log('Jestesmy w DB');
- const query = 'SELECT * FROM \"Tester\"';
- client.query(query)
- .then(res => {
- const rows = res.rows;
- rows.map(row => {
- console.log(`Read: ${JSON.stringify(row)}`);
- });
- process.exit();
- })
- .catch(err => {
- console.log(err);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement