mysql / nodejs error

Course Queries Syllabus Queries 2 years ago

0 3 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (3)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 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();
  });
});
profilepic.png
manpreet 2 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 2 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.