title: Loading an SQLite database from a byte stream in .NET
body: <p>I'm trying to load an SQLite database that will be embedded in my executable as a resource.  For those who are curious, it is because I use a small SQLite database to store configuration data, and I'd like to ship the default configuration embedded inside the executable (I hate having to carry files along with a program).</p>
  
  <p>This would just be the default configuration.  That is, I do not need to modify this configuration.  It is static and cannot be changed after my program has been built.</p>
  
  <p>I am using the System.Data.SQLite wrapper for SQLite.</p>
  
  <p>I can get access to a byte stream like this:</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>using (var stream =
            Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) {
      // use of "stream" here.
  }
  </code></pre>
  
  <p>However, I am at a loss with regards to creating an <code>SQLiteConnection</code> object from this stream.</p>
  
  <p>The easy way out would be to simply spawn a new configuration file every time the program loads, and then tell SQLite to read from that file.  This would probably work, but I would like to avoid that technique - I plan on reusing my solution to this problem to also include internationalization support (where each language is a [compressed] SQLite database and the default language is embedded in the executable - a user could add other languages my simply copying other language databases to the working directory of the program).</p>
  
  <p>I'm not concerned with the memory cost of holding this database in memory.  It will be very small (likely less than 50 KiB), so that does not bother me.  Obviously if this was a larger database, this might be an issue.</p>
  
  <p>Finally, I'm aware that this may be seen as a poor way to store a configuration.  While I agree that a plaintext-based solution is nice for cases when the user enters all his/her settings manually, this would mostly be used for settings that the user does not explicitly define.  For example, to store the positions of various docking windows in an application, or to store data about where internal resources might be found.</p>
  
  <p>Thank you for your help.</p>