# Which Databases Does DrawDB's SQL Export System Support?

> DrawDB's SQL export system supports SQLite MySQL PostgreSQL MariaDB MSSQL and Oracle SQL. Discover which databases DrawDB connects to for seamless data export.

- Repository: [drawDB/drawdb](https://github.com/drawdb-io/drawdb)
- Tags: getting-started
- Published: 2026-08-14

---

**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`](https://github.com/drawdb-io/drawdb/blob/main/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`](https://github.com/drawdb-io/drawdb/blob/main/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:

- **SQLite** (`toSqlite`): Generates SQLite-compatible DDL in [`src/utils/exportSQL/sqlite.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/sqlite.js).
- **MySQL** (`toMySQL`): Produces MySQL-specific syntax in [`src/utils/exportSQL/mysql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mysql.js).
- **PostgreSQL** (`toPostgres`): Creates PostgreSQL-compliant statements in [`src/utils/exportSQL/postgres.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/postgres.js).
- **MariaDB** (`toMariaDB`): Handles MariaDB extensions and syntax in [`src/utils/exportSQL/mariadb.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mariadb.js).
- **MSSQL (Transact-SQL)** (`toMSSQL`): Generates T-SQL for Microsoft SQL Server in [`src/utils/exportSQL/mssql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mssql.js).
- **Oracle SQL** (`toOracleSQL`): Produces Oracle-specific DDL in [`src/utils/exportSQL/oraclesql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/oraclesql.js).

## Database Identifiers in DrawDB

The supported databases are enumerated in [`src/data/constants.js`](https://github.com/drawdb-io/drawdb/blob/main/src/data/constants.js) under the `DB` constant:

```javascript
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`:

```javascript
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:

```javascript
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:

```javascript
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`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/index.js)**: The central dispatcher that routes to the appropriate database-specific generator based on `diagram.database`.

- **[`src/data/constants.js`](https://github.com/drawdb-io/drawdb/blob/main/src/data/constants.js)**: Defines the `DB` enum used to identify target databases throughout the application.

- **[`src/data/databases.js`](https://github.com/drawdb-io/drawdb/blob/main/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`](https://github.com/drawdb-io/drawdb/blob/main/mysql.js), [`postgres.js`](https://github.com/drawdb-io/drawdb/blob/main/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:

- SQLite via `toSqlite` in [`src/utils/exportSQL/sqlite.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/sqlite.js)
- MySQL via `toMySQL` in [`src/utils/exportSQL/mysql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mysql.js)
- PostgreSQL via `toPostgres` in [`src/utils/exportSQL/postgres.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/postgres.js)
- MariaDB via `toMariaDB` in [`src/utils/exportSQL/mariadb.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mariadb.js)
- MSSQL via `toMSSQL` in [`src/utils/exportSQL/mssql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/mssql.js)
- Oracle SQL via `toOracleSQL` in [`src/utils/exportSQL/oraclesql.js`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/oraclesql.js)

The system uses the `DB` enum from [`src/data/constants.js`](https://github.com/drawdb-io/drawdb/blob/main/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`](https://github.com/drawdb-io/drawdb/blob/main/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`](https://github.com/drawdb-io/drawdb/blob/main/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`](https://github.com/drawdb-io/drawdb/blob/main/src/utils/exportSQL/index.js) checks for the existence of a specific generator and defaults to returning `""` when no matching implementation is found.