Skip to content

Commit

Permalink
Merge pull request #95 from DIT112-V21/db-connection
Browse files Browse the repository at this point in the history
Connect database with the frontend app
  • Loading branch information
OneMoreOreo committed May 10, 2021
2 parents 930a98b + bb68023 commit 4c1db62
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 4,381 deletions.
37 changes: 37 additions & 0 deletions frontendApp/assets/js/db_connection.js
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")
}

}

Loading

0 comments on commit 4c1db62

Please sign in to comment.