title: Best way to access and close a postgres database using python dataset
body: <pre><code>import dataset    
  from sqlalchemy.pool import NullPool
  
  db = dataset.connect(path_database, engine_kwargs={'poolclass': NullPool})
  
  table_f1 = db['name_table']
  # Do operations on table_f1
  
  db.commit()
  db.executable.close()
  </code></pre>
  
  <p>I use this code to access a postgres database and sometimes write to it. Finally, I close it. Is the above code the best way to access and close it? Alternatively, is the code below better?</p>
  
  <pre><code>import dataset    
  from sqlalchemy.pool import NullPool
  
  with dataset.connect(path_database, engine_kwargs={'poolclass': NullPool}) as db:
      table_f1 = db['name_table']
      # Do operations on table_f1
  
      db.commit()
  </code></pre>
  
  <p>In particular, I want to make 100% sure that there is no connection to the postgres database once this piece of code is done. Which is the better way to achieve it? option 1 or option 2?</p>