Question regarding Diesel PgConnection::establish method

I have a question regarding this:

    .expect(&format!("Error connecting to {}", database_url))

of Diesel.

Is it efficient if it called every time? Or should be made reusable by using a const or static?

Connections are expensive for the server and take time to open. Use R2D2 as connection pool.

That is what I thought and that's why I asked that.

How does R2D2 play well with Diesel? I cannot find any documentation to use R2D2 with Diesel.

Enable r2d2 diesel feature.


And I also saw something here:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.