title: how to connect to postgresql with python
body: <p>I am trying to create a <code>postgresql</code> database via sqlalchemy in pycharm (running python 3.6) but have trouble connecting / creating the database. </p>
  
  <p>I initially started with <code>sqlalchemy</code> tutorial: </p>
  
  <pre><code>from sqlalchemy import create_table
  
  
  engine =create_engine("postgresql+psycopg2://scott:tiger@localhost/test")
  connection = engine.connect()
  connection.close()
  </code></pre>
  
  <p>But it print's the error: <code>could not connect to server: Connection refused (0x0000274D/10061)
      Is the server running on host "localhost" (127.0.0.1) and accepting
      TCP/IP connections on port 5432?</code></p>
  
  <p>How should I be opening up the port, or pointing it to the localhost? </p>
  
  <p>Is there any specific thing that I need to do to create the database before i run <code>create_engine</code>?</p>
  
  <p>I've also been searching online and found that perhaps I should be using <code>psycopg2</code> to create the database, but I don't understand how this is to be done. </p>
  
  <p>What I would like is to create a <code>postgresql</code> database on my desktop, in a specific folder.</p>