Error from repeated calls to connect/ disconnect
In trying to run this study from @Xintong-Li-ZnCu the repeated calls to connect and disconnect to the database here https://github.com/OHDSI/CohortMethod/blob/79b86e4435f66825cecfc8e518d0d1d034d3d4ef/R/DataLoadingSaving.R#L158 causes problems running on sidiap´s postgres database (at some point we get an error with a connect call failing). I have seen this before when working with the database myself, but avoided it by leaving the connection to the database open throughout an analysis.
My current way of getting past this for the current project has been to add the option to open the connection to the database at the start of the CodeToRun for the study package, by adding an additional argument to the function here and making this an if statement so it only connects/ disconnect if the connection is not already open and specified.
I am not sure whether you would actually want this functionality in CohortMethod (I will try and work with our database manager to see if this is just being caused by a security setting with our database that can be changed), but for awareness I thought I´d raise this as a possible issue.
Other HADES packages do allow you to provide either connectionDetails or a connection (see for example CohortDiagnostics). It would make sense to add it here as well, but a challenge is that the data fetching is often done in separate threads, and you can't share connections between threads.