title: How to determine PostgreSQL column data type based on numpy data types?
body: <p>On the Python side I have a list of signals, each signal is a <code>numpy.ndarray</code>. </p>
  
  <p>Among the signals the dtype varies - including <code>numpy.uint8</code>, <code>numpy.uint16</code>, <code>numpy.uint32</code>, <code>numpy.float64</code>, and <code>numpy.bytes_</code>.</p>
  
  <p>Eventually I'd like to pass the signals to a table in PostgreSQL, each signal being a column. I'm now stuck at the ADD COLUMN step as it's required to specify the data type for each column in PostgreSQL.</p>
  
  <p>As I use psycopg2 as the adapter, I found <a href="http://initd.org/psycopg/docs/usage.html#adaptation-of-python-values-to-sql-types" rel="nofollow noreferrer">this table</a> in the documentation but haven't found any information to help adding columns with proper data types in a dynamic way.</p>
  
  <p>My idea / approach would be - considering there're just 5 known dtype among the signals I have, I could:</p>
  
  <ol>
  <li>iterate through the list of signals</li>
  <li>get the first element of each signal, find its dtype</li>
  <li>determine the appropriate PostgreSQL data type for each signal</li>
  <li>generate a corresponding list of PostgreSQL data types</li>
  <li>use the generated list to pass data types when adding columns</li>
  </ol>
  
  <p>I'm not sure if this is the optimal way though. Is there an existing lib that does the job? Or is there a better way of coding this approach?</p>
  
  <p>Thanks for any insights!</p>