What is the best practice in Julia to share the a database connection to several functions in a module? Such as a connection from the DBInterface package.
Especially, without exporting the connection variable itself, so that the exported functions do not expose the connection? The database connection would not be a constant because it would be initialized at run time.
You could consider a global with a concrete type binding or a global constant
It’s probably a better idea to pack this into a struct and pass it around for thread safety and scalability, defaulting to an global as above for ease of use.
Another idea is to generate closures that contain the connection.
# use conn here