title: What is the proper way to handle SQLite3 queries in an electron app?
body: <p>I am trying to implement SQLite3 into my Electron app for the use of saving user preferences when the app is closed (Electron's 'close' event) and user data from an API. This API data can arrive at anytime from various parts of the script and needs to be saved. The error in question is <strong>sqlite_busy: database is locked</strong></p>
  
  <p>I have tried wrapping SQLite3's methods in a promise to be used with 'async/await' in a separate module but that only gets me so far.</p>
  
  <ul>
  <li>How can I implement it so that it saves the API data without running into 'Lock' issues?</li>
  <li>What if the app crashes or closes before the queries are finished?</li>
  <li>Would a query queue be necessary</li>
  </ul>
  
  <pre><code>// const queue = [];
  // push query to the queue
  // loop to check if the queue has a query to handle
  // execute the query and remove it from the queue
  </code></pre>