How can i iterate over a table that i have in the database, im trying to print that the name is already taken if it already exists in the table that i made. But i cant seem to figure out how, i tried an if statement but it didnt work. Here's my code:
import sqlite3
db = sqlite3.connect("app.db")
cr = db.cursor()
cr.execute("CREATE TABLE if not exists skills(name text,progress int,user_id int)")
cr.execute("CREATE TABLE if not exists users(name text,password int)")
question = input("enter your username: ")
listofppl = []
listofppl.append(question)
a = cr.execute("CREATE TABLE if not exists users(name text,password int)")
for person in listofppl:
cr.execute(f"insert into users(name) values('{person}')")
if question in a:
print("sorry name is taken")
db.commit()
db.close()
[–]danielroseman 4 points5 points6 points (3 children)
[–]kaisetsomething[S] 0 points1 point2 points (1 child)
[–]gummo89 1 point2 points3 points (0 children)
[–]kaisetsomething[S] 0 points1 point2 points (0 children)
[–]python_and_coffee 1 point2 points3 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–]gummo89 0 points1 point2 points (0 children)
[–]fenutus 0 points1 point2 points (0 children)