1. Guides
  2. Applications
  3. Performant Dashboards
  4. Existing Oltp Db
  5. Setup Connection

Step 1: Setup Connection

In this step, you'll configure MooseStack to connect to your existing OLTP database.

Overview

MooseStack needs to connect to your existing database to read data and create materialized views. This connection is configured securely and doesn't require any changes to your production database.

Configuration

moose.config.ts
import { defineConfig } from "@514labs/moose-cli"; export default defineConfig({  dataSources: {    postgres: {      type: "postgres",      host: process.env.DB_HOST || "localhost",      port: parseInt(process.env.DB_PORT || "5432"),      database: process.env.DB_NAME || "mydb",      user: process.env.DB_USER || "postgres",      password: process.env.DB_PASSWORD || "",    },  },});

Environment Variables

For security, store sensitive credentials in environment variables:

DB_HOST=your-db-host
DB_PORT=5432
DB_NAME=your-database
DB_USER=your-username
DB_PASSWORD=your-password

Verify Connection

After configuring the connection, verify it works:

moose db ping

Next Steps

Once your connection is configured, proceed to the next step to create materialized views.

On this page

OverviewConfigurationEnvironment VariablesVerify ConnectionNext Steps
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplatesGuides
Release Notes
Source518
  • Improving the Performance of Your Dashboards
  • Chat in your app
moose.config.ts
import { defineConfig } from "@514labs/moose-cli"; export default defineConfig({  dataSources: {    postgres: {      type: "postgres",      host: process.env.DB_HOST || "localhost",      port: parseInt(process.env.DB_PORT || "5432"),      database: process.env.DB_NAME || "mydb",      user: process.env.DB_USER || "postgres",      password: process.env.DB_PASSWORD || "",    },  },});