8. Database
Database Connection
The control plane and data plane require a database connection. By default in the local dev environment it connects to an in-memory (or local filesystem) sqlite database with zero-configuration.
In production, the database needs to be setup before spinning up the control plane and data plane. See Env Configuration → for the exact configuration.
The following two environment variables controls how we can connect to the databases.
OPV_DB_DRIVER
OPV_DB_CONNECTION_STR
Examples:
OPV_DB_DRIVER OPV_DB_CONNECTION_STR
============= ==============================================
"sqlite3" "file:memdb1?mode=memory&cache=shared&_fk=1"
"sqlite3" "_opv.sqlite?mode=memory&cache=shared&_fk=1"
"mysql" "root:@tcp(127.0.0.1:3306)/opv?parseTime=true"
"postgres" "postgres://user:password@host:5432/opv"
Database Visualization
Database doc can be generated by make tbls
, and the detailed README can be found on the dbdoc folder.
Supported databases
- MySQL
- Vitess(MySQL driver)
- PostgreSQL
- SQLite
- MongoDB (TODO)
- DocumentDB (TODO)
- DynamoDB (TODO)
- Redis (TODO)
Currently, OPV uses the ent framework to connect to SQL databases.