title: TypeError: __init__() got an unexpected keyword argument 'username'
body: <p>I'm trying to make my own database but I get a TypeError: __ init __() got an unexpected keyword argument 'username'. </p>
  
  <p>I followed documentation and simular stack overflows but I still get the same error. It also doesn't seem to make a difference if I have a constructor <strong>init</strong>  or use the method db.create_all().</p>
  
  <p>What am I doing wrong ? I someone is willing to help me, thank you :)</p>
  
  <pre><code>from flask import Flask, flash, redirect, render_template, request, session, url_for
  from flask_sqlalchemy import SQLAlchemy
  from flask_session import Session
  from passlib.apps import custom_app_context as pwd_context
  from tempfile import gettempdir
  
  # configure application
  app = Flask(__name__)
  
  #Flask-SQLAlchemy  https://www.tutorialspoint.com/flask/flask_sqlalchemy.htm
  app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///froshims3.db"
  db = SQLAlchemy(app)
  
  # configure session to use filesystem (instead of signed cookies)
  app.config["SESSION_FILE_DIR"] = gettempdir()
  app.config["SESSION_PERMANENT"] = False
  Session(app)
  
  class users(db.Model):
      __tablename__ = 'users'
      id = db.Column(db.Integer, primary_key = True)
      username = db.Column(db.String)
      hash = db.Column(db.String)
  
  # def __init__(self, username, password):
  #   self.username = username
  #   self.password = password
  
  #db.create_all()
  
  @app.route("/")
  def index():
      return apology("TODO")
  
  @app.route("/register", methods=["GET", "POST"])
  def register():
      """Register user."""
      if request.method == "GET":
          # redirect user to register page
          return render_template("register.html")
  
      else: 
          # query database to see if username doesn't exist.
          rows = db.session.query("SELECT * FROM users WHERE username = :username", username=request.form.get("username"))
          if len(rows) == 1:
              return apology("username already exist")
  
          # hash: http://stackoverflow.com/questions/7627752/secure-authentication-system-in-python
          hash = pwd_context.encrypt(request.form["password"])
          user = Users(request.form["username"], request.form["dorm"])
          db.session.add(user)
          db.session.commit()
          user_id = db.session.query("SELECT id from users WHERE username = :username", username=request.form.get("username"))
          session["user_id"]= user_id
      return apology("Well Done")
  </code></pre>