Solution 1
cursor.execute("SELECT * FROM logininfo WHERE Username=%s", (username,))
existingInfo = cursor.fetchone()
if existingInfo is not None:
return "Error: user is already registered" # or render_template a special error template.
Solution 2
CREATE TABLE user (id int primary key, username varchar(255), pass_hash varchar(255), UNIQUE(username))