Using tokio_postgres with actix_web

My Cargo.toml:

actix-web = "3"
serde = "1"
actix-cors = "0.5.4"
tokio-postgres = "0.7.2"

My main is started with #[actix_web::main]. In one of the handlers I would like to use tokio_postgres, but call to tokio_postgres::connect fails with:
thread 'actix-rt:worker:0' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime'

I guess I have to run actix in tokio runtime or other way round. Is there any way to do this?

Actix-web 3.X uses tokio 0.X. You need to upgrade to Actix-web 4.X to use Tokio 1.X.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.