andrijan_
Explore posts from serversDTDrizzle Team
•Created by andrijan_ on 8/21/2023 in #help
Instantiate a connection with PlanetScale in Cloudflare Workers
Hey,
What would be the right way to instantiate a database connection with PlanetScale in Cloudflare workers and reuse it across different handlers?
We cannot instantiate it outside the handler because we have no access to the environment variables :
So, we need to create a function where we can pass the env object as a parameter to access the environment variables:
And then use it in different handlers:
I wonder if this is a safe way to instantiate a connection and reuse it across different handlers with Cloudflare Workers?
2 replies