title: Find SQLite Column Names in Empty Table
body: <p>For kicks I'm writing a "schema documentation" tool that generates a description of the tables and relationships in a database.  I'm currently shimming it to work with SQLite.</p>
  
  <p>I've managed to extract the names of all the tables in a SQLite database via a query on the <code>sqlite_master</code> table.  For each table name, I then fire off a simple</p>
  
  <pre><code>select * from &lt;table name&gt;
  </code></pre>
  
  <p>query, then use the <code>sqlite3_column_count()</code> and <code>sqlite3_column_name()</code> APIs to collect the  column names, which I further feed to <code>sqlite3_table_column_metadata()</code> to get additional info.  Simple enough, right?</p>
  
  <p>The problem is that it only works for tables that are not empty.  That is, the <code>sqlite_column_*()</code> APIs are only valid if <code>sqlite_step()</code> has returned <code>SQLITE_ROW</code>, which is not the case for empty tables.</p>
  
  <p>So the question is, how can I discover column names for empty tables?  Or, more generally, is there a better way to get this type of schema info in SQLite?</p>
  
  <p>I feel like there must be another hidden <code>sqlite_xxx</code> table lurking somewhere containing this info, but so far have not been able to find it. </p>