Database Markup Language (DBML), designed to define and document database structures. See the original repository.
Using Java 21.
Example usage:
import com.wn.dbml.compiler.DbmlParser;
import com.wn.dbml.model.Database;
class ParserExample {
public static void main(String[] args) {
var dbml = """
Table table1 {
id integer
}""";
// parse the dbml
Database database = DbmlParser.parse(dbml);
// process the database structure
database.getSchemas().stream()
.flatMap(schema -> schema.getTables().stream())
.forEach(System.out::println); // prints "table1"
}
}
For more elaborate examples see the DBML-to-Avro-Translator or the
DbmlPrinter
in this repository.
Example usage:
import com.wn.dbml.compiler.DbmlParser;
import com.wn.dbml.printer.DbmlPrinter;
class PrinterExample {
public static void main(String[] args) {
var dbml = """
Table table1 {
id integer
}""";
// parse the dbml
var database = DbmlParser.parse(dbml);
// print the database structure
var printer = new DbmlPrinter();
database.accept(printer);
System.out.println(printer); // prints the above dbml
}
}
Maven dependency:
<dependency>
<groupId>io.github.nilswende</groupId>
<artifactId>dbml-java</artifactId>
<version>2.0.0</version>
</dependency>