0

when i try to load up regster.html i get this error "sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "users" does not exist LINE 1: INSERT INTO users(username,password) VALUES (NULL, NULL) ^ [SQL: INSERT INTO users(username,password) VALUES (%(username)s, %(password)s)] [parameters: {'username': None, 'password': None}] (Background on this error at: http://sqlalche.me/e/f405)"

import os
import requests
from flask import Flask, jsonify, render_template, url_for, request
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker


engine = create_engine("postgres://axrzvsvyozbgjf:fad98dd2f7b9f5347e600c4e27f03b338ac87bceb50ba5e5069545c8031c43b4@ec2-3-223-21-106.compute-1.amazonaws.com:5432/d75qlafh448r3q")
db = scoped_session(sessionmaker(bind=engine))

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("postgres://axrzvsvyozbgjf:fad98dd2f7b9f5347e600c4e27f03b338ac87bceb50ba5e5069545c8031c43b4@ec2-3-223-21-106.compute-1.amazonaws.com:5432/d75qlafh448r3q")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False



@app.route('/register', methods=["POST","GET"])
def register():
    username = request.form.get("username")
    password = request.form.get("password")
    db.execute("INSERT INTO users(username,password) VALUES (:username, :password)",
            {'username':username , 'password':password})
    db.commit()
    return render_template("register.html")


@app.route('/login', methods=["GET","POST"])
def login():
        username = request.form.get("username")
        password = request.form.get("password")
        users = db.execute("SELECT * from users").fetchall()
        db.execute("SELECT * from users WHERE username=username and password=password")
        return render_template("login.html" "username"==username, "password"==password)

You must log in to answer this question.

Browse other questions tagged .