Convert ADOC to SQL

Drag and drop files here or click to select.
Max file size 100mb.
Uploading progress:

ADOC vs SQL Format Comparison

Aspect ADOC (Source Format) SQL (Target Format)
Format Overview
ADOC
AsciiDoc Markup Language

AsciiDoc is a lightweight markup language for writing documentation, articles, and books. Created in 2002, it offers rich semantic markup with a focus on technical documentation. Supports complex structures like tables, admonitions, cross-references, and multi-file documents.

Documentation Format Technical Writing
SQL
Structured Query Language

SQL is the standard language for managing and manipulating relational databases. Developed in the 1970s at IBM, it enables creating, reading, updating, and deleting data in databases. SQL scripts contain queries, schema definitions, and data manipulation statements.

Database Language Data Management
Technical Specifications
Structure: Plain text with semantic markup
Encoding: UTF-8
Format: Human-readable text
Parser: Asciidoctor, AsciiDoc-py
Extensions: .adoc, .asciidoc, .asc
Structure: Statement-based queries
Encoding: ASCII/UTF-8
Format: Plain text script files
Parser: Database engines
Extensions: .sql
Syntax Examples

AsciiDoc syntax (documentation):

= Database Schema Documentation

== Users Table

|===
| Column | Type | Description

| id | INTEGER | Primary key
| name | VARCHAR | User name
| email | VARCHAR | Email address
|===

SQL syntax (executable):

-- Database Schema Documentation
-- Users Table

CREATE TABLE users (
    id INTEGER PRIMARY KEY,
    name VARCHAR(255),
    email VARCHAR(255)
);

-- Columns: id, name, email
Content Support
  • Document structure (chapters, sections)
  • Tables with advanced formatting
  • Source code blocks with syntax highlighting
  • Admonitions (NOTE, TIP, WARNING)
  • Cross-references and footnotes
  • Include directives for multi-file docs
  • Mathematical equations (via extensions)
  • Diagrams (PlantUML, Mermaid)
  • Data Definition Language (DDL)
  • Data Manipulation Language (DML)
  • Data Query Language (DQL)
  • Comments (single and multi-line)
  • Stored procedures and functions
  • Triggers and views
  • Constraints and indexes
  • Transaction control statements
Advantages
  • Comprehensive documentation features
  • Multiple output formats (HTML, PDF, EPUB)
  • Semantic markup for accessibility
  • Excellent for technical documentation
  • Version control friendly
  • Extensible via plugins
  • Universal database standard
  • Executable on database systems
  • Portable across SQL databases
  • Version controllable scripts
  • Reproducible database operations
  • Automation-friendly format
Disadvantages
  • Steeper learning curve
  • Not executable as database queries
  • Requires processor to render
  • Overkill for simple formatting
  • Less common than Markdown
  • Limited documentation capability
  • Only comments for explanations
  • Database-specific dialect variations
  • No rich text formatting
  • Syntax errors prevent execution
  • Security concerns (SQL injection)
Common Uses
  • Technical documentation
  • Software manuals
  • API documentation
  • Database schema documentation
  • Project wikis
  • Database schema creation
  • Data migration scripts
  • Backup and restore operations
  • Seed data insertion
  • Database queries and reports
  • Stored procedure definitions
Best For
  • Long-form documentation
  • Technical writing projects
  • Multi-chapter documents
  • Developer documentation
  • Database operations
  • Schema migrations
  • Data seeding scripts
  • Automated database tasks
Version History
Introduced: 2002 (Stuart Rackham)
Current Version: Asciidoctor 2.x
Status: Actively developed
Evolution: Python to Ruby implementation
Introduced: 1974 (IBM SEQUEL)
Standardized: SQL-86, SQL-92, SQL:2016
Status: ISO/IEC standard
Evolution: Regular ISO updates
Software Support
Editors: VS Code, IntelliJ, Atom
Processors: Asciidoctor, AsciiDoc-py
Platforms: GitHub, GitLab, Antora
Other: Jekyll, Hugo, Docbook
Databases: MySQL, PostgreSQL, SQLite
Enterprise: Oracle, SQL Server, DB2
Tools: DBeaver, DataGrip, pgAdmin
Other: All relational database systems

Why Convert ADOC to SQL?

Converting AsciiDoc documentation to SQL format is valuable when you have database schema documentation, data dictionaries, or table specifications written in AsciiDoc and need to generate executable SQL scripts. This conversion extracts structured data from your documentation and transforms it into SQL statements.

AsciiDoc is commonly used for documenting database schemas, including table structures, column definitions, data types, and relationships. When this documentation contains table specifications in AsciiDoc table format, the converter can extract this information and generate corresponding CREATE TABLE statements, INSERT statements for seed data, or other SQL operations.

This conversion is particularly useful in documentation-driven development workflows where the database schema is first documented in AsciiDoc as part of technical specifications, then converted to SQL for actual database implementation. It helps maintain consistency between documentation and implementation.

The converter extracts tabular data, code blocks containing SQL snippets, and structured content from AsciiDoc documents. AsciiDoc headings become SQL comments to preserve documentation context, while tables with column definitions can be transformed into CREATE TABLE statements or INSERT queries.

Key Benefits of Converting ADOC to SQL:

  • Documentation to Code: Generate SQL from documented specifications
  • Schema Extraction: Convert documented tables to CREATE statements
  • Data Seeding: Transform tabular data to INSERT statements
  • Consistency: Ensure docs and database match
  • Automation: Integrate into CI/CD pipelines
  • Version Control: Track both documentation and SQL changes
  • Comment Preservation: Keep documentation context as SQL comments

Practical Examples

Example 1: Table Schema Documentation to SQL

Input ADOC file (schema.adoc):

= User Management Database Schema

== Users Table

Stores user account information.

|===
| Column | Type | Constraints | Description

| id | SERIAL | PRIMARY KEY | Auto-increment ID
| username | VARCHAR(50) | NOT NULL UNIQUE | Login name
| email | VARCHAR(100) | NOT NULL UNIQUE | Email address
| created_at | TIMESTAMP | DEFAULT NOW() | Registration date
|===

== Roles Table

Defines user permission roles.

|===
| Column | Type | Constraints

| id | SERIAL | PRIMARY KEY
| name | VARCHAR(30) | NOT NULL UNIQUE
| description | TEXT | -
|===

Output SQL file (schema.sql):

-- User Management Database Schema
-- Generated from AsciiDoc documentation

-- Users Table
-- Stores user account information.

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    username VARCHAR(50) NOT NULL UNIQUE,
    email VARCHAR(100) NOT NULL UNIQUE,
    created_at TIMESTAMP DEFAULT NOW()
);

-- Roles Table
-- Defines user permission roles.

CREATE TABLE roles (
    id SERIAL PRIMARY KEY,
    name VARCHAR(30) NOT NULL UNIQUE,
    description TEXT
);

Example 2: Seed Data Documentation to INSERT Statements

Input ADOC file (seed_data.adoc):

= Initial Data Setup

== Default Categories

|===
| id | name | description

| 1 | Electronics | Phones, computers, gadgets
| 2 | Clothing | Shirts, pants, accessories
| 3 | Books | Fiction, non-fiction, textbooks
|===

== Status Codes

|===
| code | label | active

| PENDING | Pending Review | true
| APPROVED | Approved | true
| REJECTED | Rejected | false
|===

Output SQL file (seed_data.sql):

-- Initial Data Setup
-- Generated from AsciiDoc documentation

-- Default Categories
INSERT INTO categories (id, name, description) VALUES
(1, 'Electronics', 'Phones, computers, gadgets'),
(2, 'Clothing', 'Shirts, pants, accessories'),
(3, 'Books', 'Fiction, non-fiction, textbooks');

-- Status Codes
INSERT INTO status_codes (code, label, active) VALUES
('PENDING', 'Pending Review', true),
('APPROVED', 'Approved', true),
('REJECTED', 'Rejected', false);

Example 3: SQL Code Blocks Extraction

Input ADOC file (queries.adoc):

= Common Database Queries

== Get Active Users

This query retrieves all active users:

[source,sql]
----
SELECT id, username, email
FROM users
WHERE status = 'active'
ORDER BY created_at DESC;
----

== User Statistics

Get user count by registration month:

[source,sql]
----
SELECT
    DATE_TRUNC('month', created_at) AS month,
    COUNT(*) AS user_count
FROM users
GROUP BY month
ORDER BY month;
----

Output SQL file (queries.sql):

-- Common Database Queries
-- Generated from AsciiDoc documentation

-- Get Active Users
-- This query retrieves all active users:

SELECT id, username, email
FROM users
WHERE status = 'active'
ORDER BY created_at DESC;

-- User Statistics
-- Get user count by registration month:

SELECT
    DATE_TRUNC('month', created_at) AS month,
    COUNT(*) AS user_count
FROM users
GROUP BY month
ORDER BY month;

Frequently Asked Questions (FAQ)

Q: What kind of SQL is generated?

A: The converter generates standard SQL that is compatible with most relational database systems. The output uses common SQL syntax (CREATE TABLE, INSERT, SELECT) that works with MySQL, PostgreSQL, SQLite, and SQL Server. For database-specific features, you may need to adjust the generated SQL to match your target database dialect.

Q: How are AsciiDoc tables converted to SQL?

A: AsciiDoc tables are intelligently parsed based on their content. Tables with column definitions (containing type information like VARCHAR, INTEGER) are converted to CREATE TABLE statements. Tables containing data values are converted to INSERT statements. The first row is typically used as column headers or table structure definition.

Q: Are SQL code blocks preserved exactly?

A: Yes! SQL code blocks in AsciiDoc (marked with [source,sql]) are extracted and included in the output exactly as written. This is useful when your documentation already contains SQL snippets that you want to compile into a single executable script file.

Q: What happens to AsciiDoc headings and text?

A: AsciiDoc headings are converted to SQL comments (-- comment) to preserve documentation context in the generated script. Descriptive paragraphs are also converted to comments. This maintains the documentation structure within the SQL file for better readability and maintenance.

Q: Can I use the generated SQL directly in production?

A: The generated SQL should be reviewed and tested before production use. While the converter produces valid SQL syntax, you should verify that data types, constraints, and table relationships match your specific database requirements. Always test in a development environment first.

Q: Does it support database migrations?

A: The converter generates standalone SQL scripts rather than migration files for specific frameworks (like Rails migrations or Flyway). However, you can use the generated SQL as a starting point for creating migrations, or include it in your database seeding process.

Q: How are data types handled?

A: The converter recognizes common SQL data types mentioned in AsciiDoc tables (VARCHAR, INTEGER, TEXT, BOOLEAN, TIMESTAMP, etc.) and includes them in CREATE TABLE statements. If data types aren't specified, the converter may infer types from the data or use generic types that you can customize.

Q: What is the best way to document database schemas in AsciiDoc?

A: For optimal conversion, use AsciiDoc tables with clear column headers (Column, Type, Constraints, Description). Include headings for each table name, and use consistent naming conventions. Place actual SQL queries in [source,sql] code blocks. This structured approach ensures the best conversion results.