[pk]Supported Import Methods
ChartDB recognizes three import methods defined in the codebase:Smart Query
Import from database metadata JSON
DDL Import
Import from SQL DDL scripts
DBML Import
Import from DBML definitions
Automatic Format Detection
ChartDB automatically detects which import method to use based on the content structure. The detection logic is implemented indetectImportMethod:
The detection happens in order: DBML → DDL → JSON. This ensures that each format is correctly identified based on its unique patterns.
Detection Patterns
DBML Detection
ChartDB looks for these specific patterns to identify DBML format:Table Definitions
Table Definitions
Pattern:
Table table_name {References
References
Pattern:
Ref: or [ref: </-/>]Enums
Enums
Pattern:
Enum enum_name {Primary Keys
Primary Keys
Pattern:
DDL Detection
ChartDB identifies SQL DDL by looking for these keywords:- Table Operations
- Index Operations
- View Operations
- Schema Operations
- Stored Procedures
CREATE TABLEALTER TABLEDROP TABLE
JSON Detection
For database metadata queries, ChartDB looks for:- Content starting with
{and ending with} - Content starting with
[and ending with]
Import Workflow
Supported Database Types
All import methods support multiple database types:PostgreSQL
Full support including extensions, custom types, and array fields
MySQL
Complete support for MySQL 5.7+ and 8.0+
SQL Server
Microsoft SQL Server 2016+
SQLite
SQLite 3.x with full constraint support
MariaDB
MariaDB 10.2+
Oracle
Oracle Database 11g+
CockroachDB
CockroachDB with PostgreSQL compatibility
ClickHouse
ClickHouse analytics database
Import Features Comparison
| Feature | Smart Query | DDL Import | DBML Import |
|---|---|---|---|
| Tables | ✅ | ✅ | ✅ |
| Fields | ✅ | ✅ | ✅ |
| Relationships | ✅ | ✅ | ✅ |
| Indexes | ✅ | ✅ | ✅ |
| Views | ✅ | ✅ | ❌ |
| Custom Types | ✅ | ✅ | ✅ (Enums) |
| Check Constraints | ✅ | ✅ | ✅ |
| Comments | ✅ | ✅ | ✅ (Notes) |
| Default Values | ✅ | ✅ | ✅ |
| Array Types | ✅ | ✅ | ✅ (PostgreSQL) |
Error Handling
When import detection fails or content is invalid:Next Steps
Smart Query Import
Learn about importing from database metadata
DDL Import
Import SQL DDL scripts
DBML Import
Work with DBML format
