How to tell if a value exists in a sqlite3 database, python

Viewed 14152

How to tell if a value exists in a sqlite3 database, python

Here is my code so far:

def signup():
    email = request.form['email']
    username = request.form['user']
    password = request.form['password']
    g.db.execute("INSERT INTO users VALUES (?, ?, ?)", [email, username, password])
    g.db.commit()

I would like it to only insert the values into the database if email and username aren't in the database, but I have no idea where to start.

1 Answers
Related