title: How to get the equivalent of pg_dump -s <dbname> in Python (psycopg2)?
body: <p>My task is to compare the schemas of several databases in a cluster of our app in Postgres against the same databases of a different version of our app.</p>
  
  <p>The comparison should only check the schema and not data.</p>
  
  <p>The most basic way would be for me to use subproccess to execute</p>
  
  <pre><code>    pg_dump -U &lt;user&gt; -s &lt;database&gt; &gt; schema.txt
  </code></pre>
  
  <p>for each database, then run a diff.</p>
  
  <p>Two questions</p>
  
  <p>1) Is this the right approach to see if the schema has changed?
  2) Is this possible through psycopg2, without using subproccess or pg_dump or psql?</p>
  
  <p>Thanks!</p>