mysql / nodejs error

Course Queries Syllabus Queries 3 years ago

3.87K 3 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (3)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago


I have been working on fixing this problem for hours but can figure it out.

/Users/Spencer/stuq-sockets/node_modules/mysql/lib/protocol/Parser.js:82
    throw err;
          ^
Error: ER_NO_DEFAULT_FOR_FIELD: Field 'subject' doesn't have a default value
at Query.Sequence._packetToError (/Users/Spencer/stuq-sockets/node_modules/mysql/lib/protocol/sequences/Sequence.js:48:14)
at Query.ErrorPacket (/Users/Spencer/stuq-sockets/node_modules/mysql/lib/protocol/sequences/Query.js:82:18)
at Protocol._parsePacket (/Users/Spencer/stuq-sockets/node_modules/mysql/lib/protocol/Protocol.js:251:24)
at Parser.write (/Users/Spencer/stuq-sockets/node_modules/mysql/lib/protocol/Parser.js:77:12)
at Protocol.write (/Users/Spencer/stuq-sockets/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket. (/Users/Spencer/stuq-sockets/node_modules/mysql/lib/Connection.js:82:28)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket. (_stream_readable.js:745:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:407:10)
--------------------
at Protocol._enqueue (/Users/Spencer/stuq-sockets/node_modules/mysql/lib/protocol/Protocol.js:135:48)
at Connection.query (/Users/Spencer/stuq-sockets/node_modules/mysql/lib/Connection.js:184:25)
at Object. (/Users/Spencer/stuq-sockets/setup1.js:127:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

It works for almost all of my queries except for this one and I can't figure out why. Could mysql be corrupt or maybe the syntax of my query?

connection.query("insert into course(title, calendar_link, 
  syllabus_link, office_hours, "
  + "instructor, website_link, lecture_times) "
  + "values(\"" + doc["courseName"] + "\", \""
  + doc["calendar"] + "\", \"" + doc["syllabus"] + "\", \""
  + doc["officeHours"] + "\", \"" + doc["instructor"] + "\", \""
  + doc["website"] + "\", \"" + doc["lectureTime"] + "\")",
  function(err, result){
  if(err) throw err;

  c_id = result.insertId;


  tutors = doc["tutors"];
  students = doc["students"];

  addTutor_AccountTable(c_id, tutors, 0, function() {
     // Add students?
     console.log('TODO: Add students');

  });

  addStudent_AccountTable(c_id, students, 0, function() {
     connection.end();
  });
});
0 views
0 shares

profilepic.png
manpreet 3 years ago

Add subject column to your insert

or go to phpmyadmin change subject add default value or check allow null check box


0 views   0 shares

profilepic.png
manpreet 3 years ago

Add subject column to your insert

or go to phpmyadmin change subject add default value or check allow null check box


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum