Postgressql connection in next js using knex
Wed Nov 01 2023 12:19:28 GMT+0000 (Coordinated Universal Time)
Saved by
@pradhyumnsoni
#javascript
#next.js
#knex
#postgressql
import React from 'react';
const knex = require('knex');
// we require this pakages to use this - knex , oracledb , pg , pg-query-stream
// we tried with prisma but got stucked in fetching data
function page() {
const db = async () => {
const database = knex({
client: 'pg',
connection: {
host: '1.2.3.4',
port: 5432,
user: 'username',
password: 'password',
database: 'databasename'
}
});
const a = await database.from('analytics.u_kpi_essentialdata').select();
console.log('test---', a);
};
db();
return (
<div>
<div>page</div>
<div> naks</div>
</div>
);
}
export default page;
content_copyCOPY
Postgressql connection in next js
Comments