Which Databases Does DrawDB's SQL Export System Support?

DrawDB's SQL export system supports six relational databases: SQLite, MySQL, PostgreSQL, MariaDB, MSSQL (Transact-SQL), and Oracle SQL, each with dedicated DDL generators located in src/utils/exportSQL/.

DrawDB is an open-source database diagramming tool maintained at drawdb-io/drawdb that converts visual schemas into executable SQL scripts. Understanding which databases DrawDB's SQL export system supports helps developers generate accurate, dialect-specific DDL for their target database engines.

How DrawDB's SQL Export System Works

The export architecture follows a dispatcher pattern implemented in src/utils/exportSQL/index.js. This central module inspects the diagram's database property and delegates generation to a database-specific function.

The database field accepts values from the DB enum defined in src/data/constants.js. This enumeration maps human-readable database names to internal string identifiers used throughout the codebase to route export requests.

Supported Databases and Implementation Details

DrawDB provides dedicated SQL generators for six major relational engines. Each implementation resides in its own file within the exportSQL utility directory:

Database Identifiers in DrawDB

The supported databases are enumerated in src/data/constants.js under the DB constant:

export const DB = {
  MYSQL: "mysql",
  POSTGRES: "postgresql",
  MSSQL: "transactsql",
  SQLITE: "sqlite",
  MARIADB: "mariadb",
  ORACLESQL: "oraclesql",
  GENERIC: "generic",
};

Only the six concrete engines listed above possess dedicated exporters. Selecting DB.GENERIC or any unsupported identifier causes the export function to return an empty string.

Practical Examples: Exporting SQL for Different Databases

Exporting to PostgreSQL

To generate PostgreSQL DDL, set the diagram's database field to DB.POSTGRES and invoke exportSQL:

import { exportSQL } from "./src/utils/exportSQL";
import { DB } from "./src/data/constants";

const diagram = {
  database: DB.POSTGRES,
  tables: [ /* table definitions */ ]
};

const sql = exportSQL(diagram);
console.log(sql); // PostgreSQL-compatible DDL output

Exporting to MySQL

Changing the database identifier redirects the export to the MySQL generator without modifying table structures:

diagram.database = DB.MYSQL;
const mysqlSql = exportSQL(diagram);
console.log(mysqlSql); // MySQL-specific CREATE TABLE statements

Handling Unsupported Database Types

When the database property is set to DB.GENERIC or an unsupported value, the system returns an empty string:

diagram.database = DB.GENERIC;
const genericSql = exportSQL(diagram);
console.log(genericSql); // Outputs: ""

Key Source Files

Understanding the following files helps navigate DrawDB's SQL export architecture:

  • src/utils/exportSQL/index.js: The central dispatcher that routes to the appropriate database-specific generator based on diagram.database.

  • src/data/constants.js: Defines the DB enum used to identify target databases throughout the application.

  • src/data/databases.js: Contains metadata including display names, icons, and feature flags for each supported database engine.

  • src/utils/exportSQL/*.js: Individual modules (e.g., mysql.js, postgres.js) containing dialect-specific SQL generation logic.

Summary

DrawDB's SQL export system provides native support for six relational databases through dedicated generation modules:

The system uses the DB enum from src/data/constants.js to dispatch requests, falling back to an empty string for unsupported or generic database types.

Frequently Asked Questions

Does DrawDB support NoSQL databases like MongoDB?

No, DrawDB's SQL export system currently supports only relational databases. The DB enum in src/data/constants.js contains identifiers for SQLite, MySQL, PostgreSQL, MariaDB, MSSQL, and Oracle SQL. NoSQL databases such as MongoDB or Cassandra are not included in the supported export targets.

How does DrawDB handle database-specific SQL dialects?

Each supported database has a dedicated module in src/utils/exportSQL/ that implements dialect-specific syntax. For example, toPostgres handles PostgreSQL's specific data types and constraints, while toMSSQL generates Transact-SQL compatible with Microsoft SQL Server. This modular approach ensures accurate DDL generation for each target system.

Can I export SQL for multiple databases from the same diagram?

Yes, you can reuse the same diagram object and simply update the database property to target different engines. The exportSQL function in src/utils/exportSQL/index.js dynamically selects the appropriate generator based on the current diagram.database value, allowing you to produce MySQL, PostgreSQL, or other dialects from a single schema definition.

What happens if I select an unsupported database for SQL export?

If the database field is set to DB.GENERIC or any value without a corresponding export module, the system returns an empty string. The dispatcher in src/utils/exportSQL/index.js checks for the existence of a specific generator and defaults to returning "" when no matching implementation is found.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →