Connecting to an SQL database through Catalyst functions
Hey there,
Are you looking to connect to a PostgreSQL database. Here is a sample Nodejs function that can connect to a database remotely and provide scalable API endpoint to retrieve list of tables.
Here, the GET method is 'GET' and the endpoint is '/query'.
Make sure that you install express and postgres-pool packages in your advanced I/O function using "npm install --save <<package_name>>"
- var express = require('express');
- var app = express();
- const { Pool } =require('postgres-pool');
- const QUERY="SELECT * from information_schema.tables where table_schema = 'public'"
- const pool = new Pool({
- connectionString: 'postgres://user_name:password@127.0.0.1/db_name',
- });
- function getDBdata() {
- return new Promise((resolve, reject) => {
- pool.query(QUERY).then(queryResponse => {
- resolve(queryResponse.rows);
- }).catch(err => {
- reject(err);
- })
- });
- }
- app.get('/query', function (req, res) {
- getDBdata().then(
- rows => {
- var html = "<h1> List of Tables in DB</h1>";
- rows.forEach(element => {
- html = html.concat('<li>' + element.table_name + '</li><br/>');
- });
- res.send(html);
- }).catch(err => {
- console.log(err);
-
- })
- });
- module.exports = app;
Announcements
[Webinar] Build smarter HR - Payroll Automation
If your HR and payroll teams are still relying on manual exports, spreadsheet reconciliations, or constant back-and-forth coordination to keep employee data aligned, this session is for you. We’re hosting a live webinar featuring Kyle Ferrara , CTO of
[Webinar] How Raptee.HV accelerates its EV platform
Curious about how EV platforms work behind the scenes? What does it actually take to run an EV platform from onboarding users to managing connected vehicles and deploying updates seamlessly? In this session, Raptee.HV shares how their platform is built
[Webinar] Deploy Docker apps with AppSail's custom runtime | Feb. 19
Hi everyone, Join us on February 19, 2026 at 8–9 PM IST for a live Catalyst webinar demonstrating how to deploy OCI-compliant Docker images with AppSail's custom runtime. You’ll learn how to: Package your apps as Docker containers Deploy via CLI or connect
Catalyst backs Vite.js!
Hi everyone, We're happy to support the open-source ecosystem that powers modern web development! If you’re building apps with Vite, Catalyst Slate is your go-to platform to deploy blazing-fast frontend apps with ease, scalability, and zero infrastructure
Catalyst QuickML 2025 Year In Review
Hello everyone 👋 It’s been an exciting year for Catalyst QuickML. In 2025, as the Catalyst platform continued to expand its capabilities, QuickML focused on strengthening reliability, developer control, and operational readiness across the AI lifecycle.