Back to Documentation
Data Sources20 min read

Connecting Database

Learn how to connect PostgreSQL, MySQL, MongoDB, and other databases to Craveva AI for data analysis and AI agent creation.

Connecting Database

Overview

Connect your PostgreSQL, MySQL, MongoDB, and other databases to Craveva AI. Once connected, you can analyze your data, create AI agents that query your database, and build intelligent workflows.

Prerequisites

  • Database credentials (host, port, database name, username, password)
  • Network access to your database (or connection string for cloud databases)
  • Appropriate database permissions for the user account

Step-by-Step Instructions

1. Navigate to Data Sources

  1. Go to Data Sources from the main navigation
  2. Click Connect New Data Source
  3. Select Database from the available options

2. Enter Connection Details

#### For PostgreSQL, MySQL, SQL Server, Oracle:

  • Connection Name: Give your database a descriptive name (e.g., "Production PostgreSQL")
  • Database Type: Select your database type from the dropdown
  • Host/Server: Enter your database hostname or IP address
  • Port: Enter the database port (defaults are provided)
  • Database Name: Enter the name of your database
  • Username: Enter your database username
  • Password: Enter your database password
  • Schema (PostgreSQL only): Optionally specify a schema (default: "public")
  • Use SSL/TLS: Enable if your database requires SSL

#### For MongoDB:

  • Connection Name: Give your database a descriptive name
  • Database Type: Select "MongoDB"
  • Use Connection String (Recommended): Toggle this option
  • MongoDB Connection String: Enter your full MongoDB connection string
  • - Example: mongodb+srv://user:pass@cluster.mongodb.net/craveva?retryWrites=true&w=majority
  • Or use individual fields: Host, Port, Database Name, Username, Password

3. Test Connection

  1. Click Test Connection to verify your credentials
  2. Wait for the connection test to complete
  3. If successful, you'll see a green success message

4. Select Access Mode

  • Online (Live Connection): Real-time queries to your database
  • Offline (Cached Data): Use cached/synced data
  • Hybrid: Combination of both

5. Connect Database

  1. Click Connect Database
  2. Wait for the connection to be established
  3. You'll be redirected to see your connected data source

Supported Database Types

  • PostgreSQL
  • MySQL
  • MongoDB
  • SQL Server
  • Oracle
  • BigQuery
  • Snowflake
  • Redshift
  • Athena
  • ClickHouse
  • Trino
  • DuckDB

Connection String Examples

PostgreSQL

```

postgresql://username:password@host:5432/database?sslmode=require

```

MySQL

```

mysql://username:password@host:3306/database

```

MongoDB

```

mongodb+srv://username:password@cluster.mongodb.net/database?retryWrites=true&w=majority

```

Troubleshooting

Connection Timeout

  • Check your firewall rules
  • Verify the host and port are correct
  • Ensure your database allows connections from Craveva's IP addresses

Authentication Failed

  • Verify username and password are correct
  • Check if the user has the necessary permissions
  • For cloud databases, ensure IP whitelisting is configured

SSL/TLS Errors

  • Enable "Use SSL/TLS" if your database requires it
  • For cloud databases, SSL is usually required

MongoDB Connection Issues

  • Use the connection string format recommended by MongoDB Atlas
  • Ensure your MongoDB cluster allows connections from your IP
  • Check that your username and password are URL-encoded in the connection string

Next Steps

  • Go to Agent Builder to create an AI agent using this database
  • Use the Analyze feature to explore your database schema
  • Set up data mapping for your agents