title: Can you force SQLite import to halt on the first error?
body: <p>I've been using the sqlite command line tool to <code>.import</code> CSV files. From time to time we'll have a data issue in the CSV, for instance a foreign constraint violation. </p>
  
  <p>The CSV files are large (~10K records). SQLite will keep attempting the records in turn. This data is such that when there is one error then most if not all are going to have the same error. As a result:</p>
  
  <ul>
  <li>The logs are hard to use and </li>
  <li>The error cases take a long time to run (~10× normal). </li>
  </ul>
  
  <p>So I would like it to terminate on the first error.</p>
  
  <p>The relevant portion of the scripts in use look like this:</p>
  
  <pre><code>PRAGMA foreign_keys = ON;
  BEGIN TRANSACTION;
  
  -- (Some related SQL to setup other data goes here)
  
  .mode csv
  .separator ,
  .import filename.csv table_name
  
  COMMIT;
  </code></pre>
  
  <p>Is there any way to get the command line tool to terminate an import when the first error occurs?</p>
  
  <p>I looked in <a href="https://www.sqlite.org/pragma.html" rel="nofollow noreferrer">pragmas</a> but did not see anything applicable, and the <a href="https://www.sqlite.org/cli.html#csv" rel="nofollow noreferrer"><code>.import</code></a> command didn't seem to have an option for this. The <a href="https://sqlite.org/cli.html" rel="nofollow noreferrer"><code>.bail on</code></a> command doesn't cause it to stop on the error line of the CSV, just on the command which follows the CSV <code>.import</code>.</p>