title: Error in Postman 500 Internal server error api
body: <p>i'm building an api using flask for a web
  i already have a database and the GET request works but when i try POST it gives me This error</p>
  
  <blockquote>
    <p>500 INTERNAL SERVER ERROR</p>
  </blockquote>
  
  <p>This is the code i wrote</p>
  
  <pre><code>#User_schema
  class UserSchema(ma.Schema):
   class Mata:
    fields = ('id', 'name', 'Email', 'Pass', 'Phone', 'Department', 'Major')
  
  #init_schema
  user_schema = UserSchema()
  users_schema = UserSchema(many=True)
  
  #create user
  @app.route('/user', methods=['POST'])
  def add_User():
   #id = request.json['id']
   name = request.json['name']
   Email = request.json['Email']
   Pass = request.json['Pass']
   #Phone = request.json['Phone']
   Department = request.json['Department']
   Major = request.json['Major']
  
   new_user = User(name, Email, Pass, Department, Major)
   db.session.add(new_user)
   db.session.commit()
  
   return user_schema.jsonify(new_user)
  </code></pre>
  
  <p>this is the request i added on post man</p>
  
  <pre><code>{
      "name": "User 1",
      "Email": "User1@.com",
      "Pass": "qq1",
      "Phone": "0551",
      "Department": "IT 1",
      "Major": "IT 1"
  }
  </code></pre>
  
  <p>i'm also using a local server
  i looked at other links and everyone is asking for the logs and if i'm not wrong i think i get them from</p>
  
  <blockquote>
    <p>View > Developer > Show DevTools > Console</p>
  </blockquote>
  
  <p>and this is a screenshot of the log: (i think)</p>
  
  <p><a href="https://i.stack.imgur.com/x0HhH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x0HhH.jpg" alt="enter image description here"></a></p>
  
  <p>what exactly is the problem here i don't get it</p>
  
  <p>EDIT: Here is the full code:</p>
  
  <pre><code>from flask import Flask, request, jsonify
  from flask_sqlalchemy import SQLAlchemy
  from flask_marshmallow import Marshmallow
  import os
  
  app = Flask(__name__)
  basedir = os.path.abspath(os.path.dirname(__file__))
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.db'
  app.config['SQLALCHEMY_TRACK_MODIFICATION'] = False
  db = SQLAlchemy(app)
  ma = Marshmallow(app)
  
  class User (db.Model):
   id = db.Column(db.Integer,primary_key=True)
   name = db.Column(db.String(30))
   Email = db.Column(db.String(30))
   Pass = db.Column(db.String(30))
   Phone = db.Column(db.Integer)
   Department = db.Column(db.String(30))
   Major = db.Column(db.String(30))
   meeting = db.relationship('Meeting', backref='creator')
   meetingroom = db.relationship('MeetingRoom', backref='reserver')
  
      def _init_(self, name, Email, Pass, Phone, Department, Major):
    self.name = name
    self.Email = Email
    self.Pass = Pass
    self.Phone = Phone
    self.Department = Department
    self.Major = Major
  
  class MeetingRoom (db.Model):
   mrid = db.Column(db.Integer,primary_key=True)
   reserver_id = db.Column(db.Integer, db.ForeignKey('user.id'))
   #meetingm = db.relationship('Meeting', backref='roomno')
   mid = db.Column(db.Integer, db.ForeignKey('meeting.Mid'))
  
  class Meeting (db.Model):
   Mid = db.Column(db.Integer,primary_key=True)
   Mname = db.Column(db.String(100))
   Des = db.Column(db.String(100))
   Date = db.Column(db.String(20))
   creator_id = db.Column(db.Integer, db.ForeignKey('user.id'))
   meetingroomm = db.relationship('MeetingRoom', backref='mroom')
   #roomno_id = db.Column(db.Integer, db.ForeignKey('meetingroom.mrid')
  
  
  ##json 
  @app.route('/users', methods=['GET'])
  def getuser():
   users = User.query.all()
   output = []
   for user in users:
    user_data = {}
    user_data['id'] = user.id
    user_data['name'] = user.name
    user_data['Email'] = user.Email
    user_data['Pass'] = user.Pass
    user_data['Phone'] = user.Phone
    user_data['Department'] = user.Department
    user_data['Major'] = user.Major
    output.append(user_data)
   return jsonify({'users' : output})
  
  
  #User_schema
  class UserSchema(ma.Schema):
   class Mata:
    fields = ('id', 'name', 'Email', 'Pass', 'Phone', 'Department', 'Major')
  
  #init_schema
  user_schema = UserSchema()
  users_schema = UserSchema(many=True)
  
  #create user
  @app.route('/user', methods=['POST'])
  def add_User():
   #id = request.json['id']
   name = request.json['name']
   Email = request.json['Email']
   Pass = request.json['Pass']
   #Phone = request.json['Phone']
   Department = request.json['Department']
   Major = request.json['Major']
  
   new_user = User(name, Email, Pass, Department, Major)
   db.session.add(new_user)
   db.session.commit()
  
   return user_schema.jsonify(new_user)
  
  #meeting_schema
  class MeetingSchema(ma.Schema):
   class Mata:
    fields = ('Mid', 'Mname', 'Des', 'Date', 'creator_id')
  
  #init_schema
  meeting_schema = MeetingSchema()
  meetings_schema = MeetingSchema(many=True)
  
  #create meeting
  @app.route('/meeting', methods=['POST'])
  def add_meeting():
   Mname = request.json['Mname']
   Des = request.json['Des']
   Date = request.json['Date']
  
  
   new_meeting = Meeting(Mname, Des, Date)
   db.session.add(new_meeting)
   db.session.commit()
  
   return user_schema.jsonify(new_meeting)
  
  
  if __name__ == '__main__':
   app.run(debug=True)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/UxvD6.jpg" rel="nofollow noreferrer">2nd EDIT: the console log</a></p>
  
  <p>after adding def error:</p>
  
  <pre><code>cursor.execute(statement, parameters)
  sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
  [SQL: INSERT INTO user (name, "Email", "Pass", "Phone", "Department", "Major") VALUES (?, ?, ?, ?, ?, ?)]
  [parameters: ('User 1', 'User1@.com', 'qq1', '0551', 'IT 1', 'IT 1')]
  (Background on this error at: http://sqlalche.me/e/e3q8)
  </code></pre>