Database Support
Ballerina ORM supports MySQL and PostgreSQL through dialect-specific SQL generation.
Supported engines
orm:MYSQLorm:POSTGRESQL
Dialect differences
| Concern | MySQL | PostgreSQL |
|---|---|---|
| Identifier quoting | MySQL backtick quoting | PostgreSQL double-quote quoting |
| Placeholders | ? | $1, $2, ... |
| Default port | 3306 | 5432 |
| URL scheme | mysql:// | postgresql:// or postgres:// |
Placeholder examples
sql
-- MySQL
SELECT * FROM users WHERE id = ?
-- PostgreSQL
SELECT * FROM "users" WHERE "id" = $1URL 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=requireEngine selection strategy
- set
providerexplicitly when using host/port config - or use
urlfor simpler deployment config - use one engine per environment unless you intentionally test both
Next step
Go to Create Operations for task-oriented query examples.