▸ CODESCAN
DocsSupportScanner
CODESCANBOT

Database Connections

CodescanBot can do more than explain vulnerabilities — it can fix them end-to-end. When a security fix requires a database change (a stored procedure, a constraint, an index, a schema alteration), the bot generates the exact SQL or command, shows it to you for review, and executes it directly against your database with one click.

What you need before you start

A CodeScan account with an active scan session
CodescanBot open (◈ CodescanBot button in the scanner header)
A vulnerability selected that requires a database change
Connection credentials for your database (see the per-database guides below)

Supported databases

CodescanBot supports two modes for each database:

Live execution

Bot connects and runs the migration automatically

Script-only

Bot writes the migration script — you copy and run it

DatabaseModeCovers
🐘 PostgreSQLLive executionSupabase · Neon · CockroachDB · AWS RDS · Railway · Render
⚡ SupabaseLive executionSupabase Cloud (simplified URL + Service Role Key flow)
🐬 MySQL / MariaDBLive executionPlanetScale · AWS RDS MySQL · Aurora · ClearDB
🍃 MongoDBLive executionMongoDB Atlas · AWS DocumentDB · Azure Cosmos DB
🪟 SQL ServerLive executionAzure SQL Database · AWS RDS MSSQL · On-Premise
⚡ RedisLive executionRedis Cloud · Upstash · AWS ElastiCache · Heroku Redis
◉ CassandraLive executionApache Cassandra · DataStax Astra · AWS Keyspaces
◈ Oracle DBScript-onlyOracle Database · Oracle Cloud · Oracle XE
⬡ DynamoDBScript-onlyAWS DynamoDB
❄ SnowflakeScript-onlySnowflake Cloud Data Platform
◈ BigQueryScript-onlyGoogle Cloud BigQuery
🔥 FirestoreScript-onlyFirebase / Google Cloud Firestore
📁 SQLiteScript-onlyLocal development only

How to connect and run a migration

Step 1 — Open CodescanBot

  1. Go to codesscan.com/scan and scan your code
  2. Click ◈ CodescanBot in the scanner header (or press Ctrl+K)
  3. Select a vulnerability from the findings list

Step 2 — Configure your database connection

  1. In the CodescanBot panel header, click the 🗄 DB button
  2. A database panel slides open — click the tab for your database type
  3. Fill in the connection credentials (see the per-database guides below)
  4. The button shows 🗄 DB ● when credentials are entered
CODESCANBOT HEADER — DB PANEL OPEN
🐘 PostgreSQL⚡ Supabase🐬 MySQL🍃 MongoDB🪟 SQL Server⚡ Redis◉ Cassandra
PROJECT URL
https://xyz.supabase.co
SERVICE ROLE KEY
eyJ…

Step 3 — Ask the bot to fix the vulnerability

  1. Type “fix this” or click the ⚡ Apply fix chip
  2. The bot fixes the code file AND, if a DB change is needed, generates the migration automatically
  3. A DATABASE MIGRATION READY panel appears showing the exact SQL
  4. Review the SQL — then click ▶ Execute Migration (live databases) or 📋 Copy Migration Script (script-only)
  5. The result is shown immediately: ✅ success or ❌ error with the database message

PostgreSQL — connection guide

Covers Supabase, Neon, CockroachDB, AWS RDS PostgreSQL, Railway, Render, and any self-hosted PostgreSQL instance.

Option A — Connection string (recommended)

# Standard PostgreSQL URL format
postgresql://username:password@host:5432/database_name

# With SSL (required for most cloud providers)
postgresql://username:password@host:5432/database_name?sslmode=require

# Examples
postgresql://postgres:mypass@db.mycompany.com:5432/production
postgresql://user:pass@ep-xyz.us-east-2.aws.neon.tech/neondb?sslmode=require

Option B — Individual fields

FieldDescriptionDefault
HostDatabase server hostname or IPlocalhost
PortPostgreSQL port5432
DatabaseName of the database to connect topostgres
UsernamePostgreSQL userpostgres
PasswordUser password
SSLSet to true for cloud-hosted databasesfalse

Supabase — connection guide

Use the Supabase tab for the simplest setup — just your project URL and Service Role Key. CodeScan derives the correct PostgreSQL connection string automatically.

  1. Log in to supabase.com → open your project
  2. Go to Project Settings → API
  3. Copy the Project URL (format: https://xyz.supabase.co)
  4. Copy the service_role key (under Project API keys — not the anon key)
  5. Paste both into the Supabase tab in the DB panel
Why service_role? The anon key respects Row Level Security (RLS) and cannot create functions, modify schemas, or alter tables. Migrations require the service_role key which bypasses RLS and has full database access. Never expose this key in client-side code — only use it here in CodescanBot.

MySQL / MariaDB — connection guide

Covers MySQL 5.7+, MySQL 8.x, MariaDB 10.x, PlanetScale, AWS RDS MySQL, and Amazon Aurora MySQL.

# Connection string format
mysql://username:password@host:3306/database_name

# With SSL
mysql://username:password@host:3306/database_name?ssl=true

# PlanetScale (requires SSL)
mysql://user:pscale_pw_xxx@host.us-east.psdb.cloud/database?ssl={"rejectUnauthorized":true}

# AWS RDS MySQL
mysql://admin:password@mydb.abc123.us-east-1.rds.amazonaws.com:3306/mydb

Where to find credentials:

  • PlanetScale: Dashboard → Database → Connect → Create password → choose Node.js driver → copy connection string
  • AWS RDS: RDS Console → Databases → your instance → Connectivity tab → Endpoint + Port
  • Self-hosted: Use the host where MySQL is running, port 3306, and a user with ALTER and CREATE ROUTINE privileges

MongoDB — connection guide

Covers MongoDB Atlas, AWS DocumentDB, and Azure Cosmos DB for MongoDB. For MongoDB, migrations are sent as JSON commands (not SQL) that the bot formats automatically.

# MongoDB Atlas (SRV format — recommended)
mongodb+srv://username:password@cluster0.abc123.mongodb.net/myDatabase

# Standard format
mongodb://username:password@host:27017/database

# With auth source
mongodb://username:password@host:27017/database?authSource=admin

# Atlas example
mongodb+srv://codescan:MyPass123@cluster0.xyz.mongodb.net/production

Where to find your Atlas connection string:

  1. Atlas → your cluster → Connect
  2. Choose Drivers → Node.js
  3. Copy the connection string and replace <password> with your actual password
MongoDB migrations format: The bot generates MongoDB commands as JSON objects — for example {"createIndexes":"users","indexes":[{"key":{"email":1},"name":"email_unique","unique":true}]}. These run via db.command() directly.

Microsoft SQL Server — connection guide

Covers Azure SQL Database, AWS RDS for SQL Server, and on-premise SQL Server 2016+.

FieldDescriptionAzure SQL example
ServerServer hostnamemyserver.database.windows.net
PortSQL Server port1433
DatabaseDatabase namemydb
UsernameSQL loginsqladmin
PasswordSQL login password••••••
Encrypttrue for Azure SQL, false for on-prem without SSLtrue
Trust Certtrue for self-signed certs (dev/local only)false

For Azure SQL, find the server name in Azure Portal → SQL databases → your database → Overview → Server name.

Redis — connection guide

Covers Redis Cloud, Upstash, AWS ElastiCache, and Heroku Redis. Redis migrations run as commands (SET, HSET, CONFIG SET, etc.) rather than SQL.

# Connection string formats
redis://password@host:6379
redis://username:password@host:6379
rediss://password@host:6380        # rediss:// = TLS

# Upstash (always TLS)
rediss://default:AXXXpasy...@us1-abc.upstash.io:6380

# Redis Cloud
redis://:mypassword@redis-12345.c1.us-east-1-1.ec2.cloud.redislabs.com:12345

# AWS ElastiCache (no password by default, TLS optional)
redis://my-cluster.abc123.ng.0001.use1.cache.amazonaws.com:6379

Cassandra — connection guide

Covers Apache Cassandra, DataStax Astra DB, and AWS Keyspaces. Migrations run as CQL (Cassandra Query Language).

FieldDescriptionExample
Contact PointsComma-separated host(s)127.0.0.1 or node1,node2
PortCQL native transport port9042
KeyspaceKeyspace to connect tomy_keyspace
Data CenterLocal DC for load balancingdatacenter1
UsernameCassandra usercassandra
PasswordUser password••••••

Script-only databases

For Oracle, DynamoDB, Snowflake, BigQuery, Firestore, and SQLite — CodescanBot generates the correct migration syntax for the selected database but cannot execute it directly (these databases require native drivers or cloud SDKs that cannot run in a serverless environment). Instead:

  1. Select the database type in the DB panel
  2. Ask the bot to fix the vulnerability — it generates the correct migration syntax for your database
  3. A 📋 Copy Migration Script button appears instead of Execute
  4. Click it to copy the migration to your clipboard
  5. Paste and run it in your database console or CLI

Where to run script-only migrations

Oracle DB
SQL*Plus, SQL Developer, Oracle Cloud SQL Worksheet, or any Oracle-compatible client
DynamoDB
AWS Console → DynamoDB → PartiQL editor, or via AWS CLI: aws dynamodb execute-statement
Snowflake
Snowflake Web UI → Worksheets, or SnowSQL CLI: snowsql -a account -u user
BigQuery
Google Cloud Console → BigQuery → SQL editor, or bq CLI: bq query --use_legacy_sql=false
🔥 Firestore
Firebase Console, or run the generated Firebase Admin SDK script with: node migration.js
📁 SQLite
sqlite3 CLI: sqlite3 ./database.db < migration.sql, or DB Browser for SQLite

Safety and security

🔒
Credentials never storedAll database credentials are held in your browser memory only. They are never written to our database, never logged, and disappear when you close the tab.
🛡
Blocked SQL operationsDROP TABLE, DROP DATABASE, TRUNCATE, DELETE without WHERE, DROP COLUMN, GRANT ALL, and file read operations are blocked server-side before execution — even if someone crafts a malicious migration.
👁
Always shown before executionThe full SQL or command is always displayed in the migration panel. You review it and click Execute — the bot cannot run anything silently.
Rollback SQL includedFor complex migrations, the bot also generates rollback SQL so you can undo the change if something breaks.
🔐
Use least-privilege credentialsCreate a dedicated database user for CodeScan with only the permissions needed: CREATE FUNCTION, CREATE INDEX, ALTER TABLE (additive). Never use root or admin credentials.

Troubleshooting

No database connection configured
You must fill in at least one credential field in the DB panel before clicking Execute Migration. Click 🗄 DB in the CodescanBot header to open the panel.
Connection timeout
Check that your database host is reachable from the internet. Cloud-hosted databases (AWS RDS, Azure SQL) may need an inbound firewall rule allowing connections from Vercel's IP range.
Authentication failed / Access denied
Double-check your username and password. For Supabase, make sure you are using the service_role key, not the anon key. For MySQL, confirm the user has the required privileges.
SSL required / SSL connection error
Set SSL to true in the connection fields. Most cloud databases require SSL. For self-hosted databases with self-signed certs, also set Trust Certificate to true.
Blocked operation detected
The migration contains a destructive statement (DROP TABLE, TRUNCATE, etc.) that is blocked for safety. Ask CodescanBot to rewrite the migration without destructive operations.
MongoDB command must be valid JSON
MongoDB migrations must be formatted as a JSON object, not JavaScript. Example: {"createIndexes":"users","indexes":[...]} — make sure all keys and strings are double-quoted.
ECONNRESET / ENOTFOUND
The database host cannot be reached. Check the hostname spelling and ensure the database server is running. For local databases, note that the execution runs on Vercel's servers — localhost will not work.

Quick reference

# ── Open CodescanBot ──────────────────────────────────────────────
# Click ◈ CodescanBot in scanner header  OR  Ctrl+K

# ── Connect your database ─────────────────────────────────────────
# Click 🗄 DB  →  pick database tab  →  fill credentials
# Green dot (🗄 DB ●) = credentials entered

# ── Trigger a migration ───────────────────────────────────────────
# Select a vulnerability  →  ask bot to "fix this"
# Bot patches code + proposes DB migration
# Click ▶ Execute Migration  (live databases)
# Click 📋 Copy Migration Script  (script-only databases)

# ── Connection string formats ─────────────────────────────────────
# PostgreSQL   postgresql://user:pass@host:5432/db?sslmode=require
# Supabase     Project URL + service_role key  (use Supabase tab)
# MySQL        mysql://user:pass@host:3306/db
# MongoDB      mongodb+srv://user:pass@cluster.mongodb.net/db
# SQL Server   host + port + db + user + pass  (use SQL Server tab)
# Redis        redis://:password@host:6379
# Cassandra    host + keyspace + datacenter + credentials