Bot Uptime

Connecting Your Bot to Managed MySQL, PostgreSQL, MongoDB & Redis

Flat JSON files corrupt when two events write at the same time. Every Bot Uptime plan includes built-in Managed Databases (1 on Free, 5 on Developer, 15 on Pro) across MySQL (MariaDB), PostgreSQL 16, MongoDB 7, and Redis 7. Databases run on an internal host reachable directly from your bot containers with zero public internet exposure.

1. Provision a Database in One Click

Open Dashboard → Databases, pick an engine (MySQL, PostgreSQL, MongoDB, or Redis), enter a short label like "economy-db", and click Create Database. Copy the generated Connection URI into your bot’s .env file as DATABASE_URL (or REDIS_URL).

2. Connect from Node.js (MySQL, PostgreSQL, MongoDB, Redis)

Every standard driver works out of the box with the exact URI shown in your dashboard. For Redis, remember your account uses a dedicated ACL key prefix (for example bu_a1b2c3:) so other users can never read or overwrite your keys.

database-examples.js
// 1) MySQL (npm install mysql2)
const mysql = require('mysql2/promise');
const pool = mysql.createPool(process.env.DATABASE_URL);
const [rows] = await pool.query('SELECT 1 AS ok');

// 2) PostgreSQL (npm install pg)
const { Pool } = require('pg');
const pg = new Pool({ connectionString: process.env.DATABASE_URL });
const res = await pg.query('SELECT NOW()');

// 3) MongoDB (npm install mongodb)
const { MongoClient } = require('mongodb');
const mongo = new MongoClient(process.env.DATABASE_URL);
await mongo.connect();
const db = mongo.db();

// 4) Redis (npm install ioredis) — always prefix keys with REDIS_PREFIX!
const Redis = require('ioredis');
const redis = new Redis(process.env.REDIS_URL);
await redis.set(process.env.REDIS_PREFIX + 'welcome:123', 'enabled');

3. Connect from Python (asyncpg / aiomysql / motor / redis)

Always use async database drivers inside discord.py or python-telegram-bot so queries never block your event loop.

db_python.py
import os, asyncpg, redis.asyncio as aioredis

# PostgreSQL (pip install asyncpg)
pool = await asyncpg.create_pool(os.environ["DATABASE_URL"])
val = await pool.fetchval("SELECT 1")

# Redis (pip install redis) — always prefix keys with your assigned ACL prefix!
r = aioredis.from_url(os.environ["REDIS_URL"], decode_responses=True)
await r.set(os.environ["REDIS_PREFIX"] + "guild:123", "active")

Frequently Asked Questions

Can another user access my database?

No. Every MySQL, PostgreSQL, and MongoDB database gets its own randomly generated database name, username, and 24-character password scoped strictly to that single database. Redis uses per-user Redis 7 ACLs restricted to your unique key prefix.

Can I rotate my database password anytime?

Yes — open Dashboard → Databases and click Rotate Password on any database, then update DATABASE_URL in your bot’s .env file.

Ready to deploy your bot 24/7?

Launch a custom Discord, Telegram, or WhatsApp container (Python, Node.js, Java, Rust) with Managed Databases and Free AI Agents — or deploy a ready-made Discord bot in 1 click on Bot Uptime.