title: postgres creating database using .sql file
body: <p>So I have been trying to create a database using a .sql file. 
  The first time we do it, it works perfectly, but it has to work everytime.
  If I create a database in postgres myself, the script works perfectly, but if I haven't made the database manually, the script says: psql:<em>script_name</em>:40: ERROR: database <em>dbname</em> does not exist.</p>
  
  <p>This is the code: </p>
  
  <pre><code> --dit is een psql die eerst de database project dropt, vervolgens
  --maakt hij opnieuw de database project aan.
  --De de tabellen die hierbij worden gemaakt zijn:
  --Pathway_C1, Eiwit_C1, Gen_C1, Gen_Go_C1, Go_termen_c1 en Gen_kegg_C1
  
  --
  -- PostgreSQL database dump
  --
  
  -- Dumped from database version 9.5.14
  -- Dumped by pg_dump version 9.5.14
  
  SET statement_timeout = 0;
  SET lock_timeout = 0;
  SET client_encoding = 'UTF8';
  SET standard_conforming_strings = on;
  SELECT pg_catalog.set_config('search_path', '', false);
  SET check_function_bodies = false;
  SET client_min_messages = warning;
  SET row_security = off;
  
  
  --
  -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
  --
  
  CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
  
  
  --
  -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
  --
  
  COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
  
  
  SET default_tablespace = '';
  
  SET default_with_oids = false;
  
  DROP DATABASE project;
  
  CREATE DATABASE project; 
  
  \c project
  
  CREATE TABLE Pathway_C1 (
      Kegg_co CHAR(8) NOT NULL,
      PRIMARY KEY (Kegg_co)
  );
  
  CREATE TABLE Go_termen_C1 (
      Go_nummer CHAR(10) NOT NULL,
      Go_functie VARCHAR(1000) NOT NULL,
      PRIMARY KEY (Go_nummer)
  );
  
  CREATE TABLE Gen_C1 (
      Gen_ID INTEGER NOT NULL,
      Gen_naam VARCHAR(50) NOT NULL,
      PRIMARY KEY (Gen_ID)
  );
  
  
  CREATE TABLE Eiwit_C1 (
      Eiwit_ID CHAR(12) NOT NULL,
      Gen_ID INTEGER NOT NULL,
      Eiwit_naam VARCHAR(500) NOT NULL,
      Eiwit_Lengte INTEGER NOT NULL,
      PRIMARY KEY (Eiwit_ID),
      FOREIGN KEY (Gen_ID) REFERENCES Gen_C1(Gen_ID)
  );
  
  CREATE TABLE Gen_Kegg_C1 (
      Gen_ID INTEGER NOT NULL,
      Kegg_co CHAR(8) NOT NULL,
      PRIMARY KEY (Gen_ID, Kegg_co),
      FOREIGN KEY (Kegg_co) REFERENCES Pathway_C1(Kegg_co),
      FOREIGN KEY (Gen_ID) REFERENCES Gen_C1(Gen_ID)
  );
  
  CREATE TABLE Gen_Go_C1 (
      Gen_ID INTEGER NOT NULL,
      Go_nummer CHAR(10) NOT NULL,
      PRIMARY KEY (Gen_ID, Go_nummer),
      FOREIGN KEY (Gen_ID) REFERENCES Gen_C1(Gen_ID),
      FOREIGN KEY (Go_nummer) REFERENCES Go_termen_C1(Go_nummer)
  );
  
  
  
  GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO username; 
  
  --
  -- Name: SCHEMA public; Type: ACL; Schema: -; Owner: -
  --
  
  REVOKE ALL ON SCHEMA public FROM PUBLIC;
  REVOKE ALL ON SCHEMA public FROM postgres;
  GRANT ALL ON SCHEMA public TO postgres;
  GRANT ALL ON SCHEMA public TO PUBLIC;
  
  
  
  --
  -- PostgreSQL database dump complete
  --enter code here
  </code></pre>
  
  <p>Please don't pay attention to the comments we put in the script, they are not really important. </p>