Skip to content
Advertisement

How to use flask variable in calling SELECT query in MariaDB

What is the correct syntax for calling a SELECT query in MariaDB from a Registration Form. Specifically, in the WHERE clause. I’ve been looking all over the net to debug this and it does not seem to work (semantically).

Here is the code in my python flask.

JavaScript

“”The visEmail is the variable that is supposed to be holding the email address given by the user upon clicking submit, the program then checks in the database if the given email address already exists in the DB.

I printed the data in the visEmail variable to see the string(Which is fine), but the execution in the database returns me with “None” (It should not be returning a None since I already have the given email address on the DB). It is supposed to return the error “Email Already exists”

THank you very much

Advertisement

Answer

You’re not fetching the row of results. cur.execute() doesn’t return anything, you have to call cur.fetchone() to get the results, and assign that to current_Email.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement