Whenever I collect data from my database, it is stored as
@app.route('/signup', methods=["GET", "POST"])
def add_data():
p = request.form['password']
p2 = request.form['password_c']
if p == p2:
db = get_db()
e = request.form['email']
e2 = db.execute('SELECT Email FROM Users').fetchall()
if e in e2:
return render_template('Exist2.html', title="Login Page")
else:
if request.method == "POST":
fname = request.form['fname']
sname = request.form['sname']
address = request.form['address']
email = request.form['email']
password = request.form['password']
key = Fernet.generate_key()
f = Fernet(key)
encrypted_address = f.encrypt(bytes(address, 'utf-8'))
encrypted_password = generate_password_hash(password)
db = get_db()
db.execute('INSERT INTO Users'
'(First_Name, Surname, Address, EKey, Password, Email)'
'VALUES (?, ?, ?, ?, ?, ?)',
(fname, sname, encrypted_address, key, encrypted_password, email))
db.commit()
return render_template('Success.html', title='Login Page', variable=e2)
else:
return render_template('False.html', title='Home Page')
And my html code is:
{% extends "base.html" %}
{% block content %}
Sign Up:
{% block error_false %}
{% endblock %}
{% endblock %}
This code is for a sign up page and I'm trying to check if the email entered already exists in the database with e2 = db.execute('SELECT Email FROM Users').fetchall() which should give a list of all the Emails which I can then check with the entered email but instead I get given: [
I've tried .fetchall() which seems to work for others not using Flask but not for me. I also tried singular queries, but it still gave the same error.
EDIT: Thanks @Serg, that worked. Only issue, If I wanted to find what the variable was, I would only be able to try options until I find out. Is there a way I can find out without trial and error? I've tried sending the output to python console and the html page but neither worked.
EDIT 2: Also, I'm trying to use hashing and check if the database entered hash is the same as the entered password but using this method is impossible because of random additions when hashing making them unable to cracked using Rainbow Table Attacks. Could I instead convert sqlite3.Row objects into plaintext?