Skip to main content

establish_connection

Function establish_connection 

Source
pub fn establish_connection() -> MysqlConnection
Expand description

This function establishes a connection to the MySQL database.

Note that the connection has to be set in a configuration file called .env, with the following format:

DATABASE_URL=mysql://username:password@localhost/database_name

§Returns

A MysqlConnection object representing the connection to the database.

§Usage

This function is used to establish a connection to the MySQL database. It is usually called with:

let connection = &mut establish_connection();