-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from DIT112-V21/db-connection
Connect database with the frontend app
- Loading branch information
Showing
3 changed files
with
115 additions
and
4,381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
let config = require('electron-node-config'); | ||
let dbConfig = config.get('database.dbConfig'); | ||
const {Connection}= require ('postgresql-client') | ||
const {Client}= require('pg') | ||
const client = new Client({ | ||
|
||
host: dbConfig.host, | ||
port: dbConfig.port, | ||
database: dbConfig.dbName, | ||
user: dbConfig.dbUser, | ||
password: dbConfig.dbPassword | ||
|
||
}) | ||
|
||
execute() | ||
|
||
async function execute(){ | ||
try{ | ||
|
||
|
||
await client.connect() | ||
console.log("Connect successfuly") | ||
const results= await client.query("select * from public.missions") | ||
console.table(results.rows) | ||
|
||
|
||
} | ||
catch{ | ||
console.log("Error") | ||
} | ||
finally{ | ||
await client.end() | ||
console.log("disconnected") | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.