title: Why is my query working on pgAdming but when I execute it from the server I get a query error (Error: Connection Terminated)?
body: <p>I'm working on my Capstone project and it requires to store some telemetry data on a database. I'm using PostgreSQL 9.5 for the database and node for the server. </p>
  
  <p>My problem is that when I try to send a query from the server I'm getting a query error [Error: Connection Terminated]. If I use <code>JSON.stringify(err)</code> I only see empty brackets as the result <code>{}</code>. What is interesting is that if I use pgAdmin client and execute the same query, the record is added successfully without any kind on error.</p>
  
  <p>Here is the code I'm using in the server to send the query:</p>
  
  <pre class="lang-js prettyprint-override"><code>client.connect(function(err) {
      if(err){
          return console.error('could not connect to postgres', err);
      }
  
      //Checks if there is survey data to process
      if(surveyFlag){
  
          //Query to insert survey record
          //Returns survey record's auto-generated id to use it when creating or updating the             //telemetry record in the database 
          var query = 'INSERT INTO survey_response (perceived_risk, actual_risk) '+
                      'VALUES (' + telemetryRecord.survey.perceivedRisk +', ' +                   
                                   telemetryRecord.survey.actualRisk +') ' +
                      'RETURNING survey_id';
  
          client.query(query, function(err, result) {
  
          console.log("Query: " + query);
  
                  if(err) {
                      console.log(err);
                      return console.error('error running survey query', err);
                  }
  
                  surveyID = result.rows[0].survey_id;    
  
                  //Testing
                  console.log ("Survey response added with ID: " + surveyID);
  
  
          });
  
              //Close the connection  
          client.end();
  });
  </code></pre>