Function event_db::establish_connection
source · pub async fn establish_connection(url: Option<&str>) -> Result<EventDB, Error>
Expand description
Establish a connection to the database, and check the schema is up-to-date.
Parameters
url
set to the postgres connection string needed to connect to the database. IF it is None, then the env var “DATABASE_URL
” will be used for this connection string. eg: “postgres://catalyst-dev:CHANGE_ME@localhost/CatalystDev
”
Errors
This function will return an error if:
url
is None and the environment variable “DATABASE_URL
” isn’t set.- There is any error communicating the the database to check its schema.
- The database schema in the DB does not 100% match the schema supported by this library.
Notes
The env var “DATABASE_URL
” can be set directly as an anv var, or in a
.env
file.