عندي مشكله بالكود ابي اذا احد كتب id مستخدم من قبل يطلع له تنبيه ان هذا ال id مستخدم من قبل وش الكود الي اكتبه بالضبط ؟
from pywebio.input import *
from pywebio.output import *
import sqlite3
mydb=sqlite3.connect("cvdb.db")
cr=mydb.cursor()
def create_db():
cr.execute('''CREATE TABLE if not exists cv ( id int, name varchar(255), age varchar(255), PRIMARY KEY (id) ) ''') create_db()
def select_user_type():
user_type=radio("Select the type of user",["New User","Old User"])
if user_type=="New User":
registration_form()
else:
search_user()
def registration_form():
data=input_group("Enter your data:",[
input("Enter your id:",name='id',type=NUMBER),
input("Enter your name:",name='name',type=TEXT), input("Enter your age:",name='age',type=NUMBER), ] ) cr.execute(f'''INSERT INTO cv(id, name, age) VALUES ('{data['id']}','{data['name']}','{data['age']}')''')
mydb.commit()
mydb.close()
put_table([ ["id", "Name", "Age"], [data['id'],data['name'], data['age']], ])
return data
def search_user():
id=input("Enter your id:",type=NUMBER)
command=f'''SELECT * FROM cv WHERE id='{id}'; ''' cr.execute(command) x=cr.fetchone() if x==None: popup("I can't find this id, please enter the correct id")
search_user()
else:
put_text("Your contact information ")
put_table([ ["id","Name", "Age"], [x[0],x[1],x[2]], ]) select_user_type()
app.py