title: How to set pgpassword and run postgres command in one line using Python?
body: <p>I'm trying to set pgpassword and run pg command in one line but not working,</p>
  
  <p>I'm using Windows.</p>
  
  <pre><code>os.system('SET PGPASSWORD=admin &amp;&amp; psql -U postgres -c "CREATE DATABASE TEST"')
  </code></pre>
  
  <p>what I got: </p>
  
  <blockquote>
    <p>psql: FATAL:  Ident authentication failed for user "postgres"</p>
  </blockquote>
  
  <p>It's weird because it's the password</p>
  
  <p>How can I solve this?</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>SOLVED</p>
  
  <pre><code>cmd1 = 'SET PGPASSWORD=admin'
  cmd2 = 'psql -U postgres -c "CREATE DATABASE TEST"'
  os.system(cmd1 + '&amp;&amp;' + cmd2)
  </code></pre>