Connect to a PostgreSQL Database
Connect to a PostgreSQL database and run dynamic scripts through that library. The library is responsible for connecting to the database, executing the script and closing the connection after execution.
const postgresql = require('linkapi-sdk/state/postgresql');
const config = {
credentials: {
"host": "",
"user": "",
"password": "",
"port": "",
"database": ""
},
query: 'SELECT * FROM {{table}}',
queryValues: {
table: 'PRODUCTS'
}
}
const options = {
rawResult: false // optional, returns full result instead of only rows - default: false
};
const result = await postgresql.execute(config, options);
Updated over 4 years ago