title: Calling sqlite3_close for a static sqlite3* handle
body: <p>I want to provide access an sqlite database in Objective C. I don't want the caller to bother about the DB itself and so I intend to do something like this in my DataStore.m:</p>
  
  <pre><code>#import "DataStore.h"
  #import &lt;sqlite3.h&gt;
  
  static sqlite3 *database = nil;
  
  @implementation DataStore
  
  + (void) initialize {
  
    if(self != [DataStore class])
      return;
  
    ...
    ...
  
    sqlite3_open(databasePath, &amp;database);
  }
  
  + (NSArray *) readWith:foo:bar {
    ...
  }
  
  + (bool) writeWith:foo:bar {
    ..
  }
  </code></pre>
  
  <p>Now the problem with the whole thing is: I will never get to call sqlite3_close throughout the entire application. It certainly does not look elegant. How could I improve this?</p>
  
  <p>One way would be to open and close my database on each access, and get rid of the static DB handle. How costly would it be?</p>
  
  <p>PS: I don't have a strong OO background and so if my idea is bad, I don't mind changing it altogether.</p>