title: How to connect to PostgreSQL in Erlang using epgsql driver?
body: <p>I would like to access a PostgreSQL database in Erlang. I downloaded the <a href="https://github.com/wg/epgsql" rel="nofollow">epgsql</a> driver, it was a few directories and files, but I don't understand how to use it.</p>
  
  <p>How can I write an Erlang program and use the epgsql driver to access a PostgreSQL database?</p>
  
  <p>I made a new folder and copied all files from <code>src/</code> in the driver and <code>pgsql.hrl</code> to my new folder. Then I created a simple test program:</p>
  
  <pre><code>-module(dbtest).
  -export([dbquery/0]).
  
  dbquery() -&gt;
      {ok,C} = pgsql:connect("localhost", "postgres", "mypassword",
                                       [{database, "mydatabase"}]),
      {ok, Cols, Rows} = pgsql:equery(C, "select * from mytable").
  </code></pre>
  
  <p>Then I started erl and compiled the modules with <code>c(pgsql).</code> and <code>c(dbtest)</code>.
  But then when I exeute <code>dbtest:dbquery().</code> I get this error:</p>
  
  <pre><code>** exception error: undefined function pgsql:connect/4
       in function  dbtest:dbquery/0
  </code></pre>
  
  <p>Any suggestions on how I can connect to a PostgreSQL database using Erlang?</p>