Best Practice for interacting with Databases (opening and closing DB connection)

Hi All,

When connecting with a database that you may be interacting with multiple times during a process (storing config data on DB instead of excel configs, writing log data to DB etc., extracting/updating data from DB tables) Is it best practice to open the DB connection just once in init state of the Framework and then close it in end state or open and close the connection each time you want to interact with the DB so you aren’t leaving the connection open for potentially a long time?

Thanks all,

@charliefik

I think this might help

And also it depends on how long the process runs as well…if its too long then its better to disconnect and connect which does not keep unecessary process live

Cheers

1 Like

It is best to open the DB connection just once in the Init and Reuse the connection through out your workflow.
Please ensure that the DB connection is disconnected at some point of time preferably in the End state if you are opening the connection in the init state.

1 Like

Thanks Anil and Vish. I’ll go with the open in init and close in end process (if using framework)

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.