title: C++/SQLite - db access with multiple processes
body: <p>I would like to write with several processes in a SQLite database. Here is my c++ code:</p>
  
  <pre><code>stringstream sstream &lt;&lt; "BEGIN;" &lt;&lt; query &lt;&lt; "COMMIT;";
  
  sqlite3_busy_timeout(databasePtr, 60000); // set timeout if sql busy
  
  if((result = sqlite3_exec(databasePtr, (sstream.str()).c_str(), NULL, NULL, NULL)) != SQLITE_OK){
      /** ERROR or SQLITE_BUSY **/
  }    
  
  sqlite3_busy_timeout(databasePtr, 0); // reset sql_busy handler
  </code></pre>
  
  <p>I thought that the sqlite3_busy_timeout leads to success. But I've checked the results and found that not all data is written to the database. Where is my mistake?</p>
  
  <p>Does someone knows how often sqlite3_exec is called when the sqlite3_busy_timeout is set to 60000 (ms)? Or is there only one call after 60000 (ms) if the first try returns with SQLITE_BUSY?</p>
  
  <p>I've tried to fix the problem with the following code. But it looks like there is only one active process all the time. The other processes will not finished...</p>
  
  <pre><code>do{
      if((result = sqlite3_exec(databasePtr, (sstream.str()).c_str(), NULL, NULL, NULL)) != SQLITE_OK){
          if(result == SQLITE_BUSY){
              sleep(60000); // sleep 10 sec
          }else{
              /** ERROR **/
          }
      }
  }while(result == SQLITE_BUSY);
  </code></pre>