importos
name_list= ['id', 'name', 'age', 'phone', 'job'] #创建列名列表
ditons=['>','
user_dic={'name':'admin','passwd':'123456'}
status={'name':None,'passwd':False,'login':False}defauth(x):def user_auth(*args,**kwargs):if not status['login']:#获取user_dic字典里面的login值
username=input('请输入用户名')
userpasswd=input('请输入密码')if username==user_dic['name'] and userpasswd==user_dic['passwd']:#判断账户密码是否正确
status['name']=username #如果正确修改user_dic里面的信息
status['passwd']=userpasswd
status['login']=Trueprint('登陆成功')
res=x(*args,**kwargs)returnreselse:print('用户名或密码输入错误')else:#如果login为True,直接执行函数
res=x(*args,**kwargs)returnresreturn user_auth#函数闭包
defcheck():
s=input('请输入查询语句,例如 select * where age=25\n')if 'select' and 'where'in s:#检查输入语句是否正确
content, condition = s.split('where') #以where分割s,并且赋值给content,condition
content = ''.join(content.split('select')[1:]) #content 以select分割,取最后一个赋值给content
if content.strip() and condition.strip(): #判断 如果content 和condition都不为空,执行下面语句
for key in ditons: #for循环遍历ditions,
if key in condition: #如果key 在condition里面的话,执行下列语句
index_condition = ditons.index(key)#获取key在ditons里面的索引
name, cond = condition.strip().split(key)#以key分割condition,赋值给name,cond
if name in name_list:#如果name在name_list里面,执行下列语句
with open('mysql', encoding='u