Actually, you should be able to provide a database instance (not a connection string, not a hostname, an *instance*) as an argument to a library or function, with that library or function not needing to care about where the data is persisted exactly
(This implies it being compartmentalized or composable in some way, such that the library or function also does not need to care about trampling something else's data)