title: PyQt - How to close database connection on class destruction
body: <p>If my class uses a database quite a few times (a lot of functions/properties use data from the DB), what's the best practice: to create a DB connection once at the start of the class, do whatever so many times, and then close the DB connection on exit (using global variables); or to create/use/close DB connections in every property (using local variables)?</p>
  
  <p>If it's better to start a connection once and close it on class destruction, how can I do this? </p>
  
  <pre><code>def __del__ (self)
      self.connection.close()
  </code></pre>
  
  <p>doesn't work.</p>
  
  <p>Thank you.</p>