title: EXIT CODE 1 when restore sql file in postgres
body: <p>I have an SQL file which is manually generated. I use the code below to create it.</p>
  <pre><code>conn = psycopg2.connect(host=t_host, port=t_port, dbname=t_dbname, user=t_name_user, password=t_password)
  cursor = conn.cursor()
  
  table_name='product'  
  with open(&quot;table_dump.sql&quot;,&quot;w+&quot;) as f:
      create_query =&quot;&quot;&quot;CREATE TABLE public.decima
                      (
                          product_name character varying(200) COLLATE pg_catalog.&quot;default&quot;,
                          product_owner character varying(20) COLLATE pg_catalog.&quot;default&quot;,
                          trigger_operation character varying(4) COLLATE pg_catalog.&quot;default&quot;,
                          name character varying(250) COLLATE pg_catalog.&quot;default&quot; NOT NULL,
                          CONSTRAINT product_pkey PRIMARY KEY (name)
                      )
  
                      TABLESPACE pg_default;&quot;&quot;&quot;
      f.write('%s \n' % (create_query))  
      #select table query
      cursor.execute(&quot;SELECT * FROM %s&quot; % (table_name)) 
      column_names = []
      columns_descr = cursor.description
      for c in columns_descr:
          column_names.append(c[0])
      #insert query (insert data)
      insert_prefix = 'INSERT INTO %s (%s) VALUES ' % (table_name, ', '.join(column_names))
      rows = cursor.fetchall()
      for row in rows:
          row_data = []
          for rd in row:
              if rd is None:
                  row_data.append('NULL')
              elif isinstance(rd, datetime.datetime):
                  row_data.append(&quot;'%s'&quot; % (rd.strftime('%Y-%m-%d %H:%M:%S') ))
              else:
                  row_data.append(repr(rd))
          f.write('%s (%s);\n' % (insert_prefix, ', '.join(row_data)))  
  </code></pre>
  <p>When I used &quot;table_dump.sql&quot; to restore db, the exit code appeared. But I executed this file as a query, then my database still be created and work as usual.
  So how can to fix this problem. Thank you.
  This is the way I tried to restore
  <a href="https://i.stack.imgur.com/pMkIF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pMkIF.png" alt="The way that I restore the file" /></a>
  <a href="https://i.stack.imgur.com/vejzl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vejzl.png" alt="my table_dump.sql" /></a>
  This is the detail of error
  <a href="https://i.stack.imgur.com/othkI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/othkI.png" alt="The detail of error" /></a></p>