Open ecomodeller opened 5 months ago
https://github.com/DHI/mikepluspy/blob/024977cdd21ffcede755e93bfa1a5ac19d4aa5bf/tests/test_datatable.py#L16
Instead of:
data_access.open_database() muids = data_access.get_muid_where("msm_Link", "MUID='link_test'") data_access.close_database()
it will be
with data_access.open_database() muids = data_access.get_muid_where("msm_Link", "MUID='link_test'") ... # db connection is closed at the end of the with block
Closing databases is typically done with automatically with a context manager. https://realpython.com/python-with-statement/#the-with-statement-approach
Equivalent to using in C# https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/using
using
https://github.com/DHI/mikepluspy/blob/024977cdd21ffcede755e93bfa1a5ac19d4aa5bf/tests/test_datatable.py#L16
Instead of:
it will be
Closing databases is typically done with automatically with a context manager. https://realpython.com/python-with-statement/#the-with-statement-approach
Equivalent to
using
in C# https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/using