Database Support

Ballerina ORM supports MySQL and PostgreSQL through dialect-specific SQL generation.

Supported engines

  • orm:MYSQL
  • orm:POSTGRESQL

Dialect differences

ConcernMySQLPostgreSQL
Identifier quotingMySQL backtick quotingPostgreSQL double-quote quoting
Placeholders?$1, $2, ...
Default port33065432
URL schememysql://postgresql:// or postgres://

Placeholder examples

sql
-- MySQL
SELECT * FROM users WHERE id = ?

-- PostgreSQL
SELECT * FROM "users" WHERE "id" = $1

URL parsing behavior

The URL parser supports:

  • provider detection from URL scheme
  • optional credentials
  • IPv6 host notation
  • query-string parsing for additional params
text
mysql://user:pass@localhost:3306/myapp
postgresql://user:pass@localhost:5432/myapp?sslmode=require

Engine selection strategy

  • set provider explicitly when using host/port config
  • or use url for simpler deployment config
  • use one engine per environment unless you intentionally test both

Next step

Go to Create Operations for task-oriented query examples.