q7 = [] for attr in a6["setattr"]: q7.append({ "type": "input", "message": "Enter {} ({})".format(attr, attrs[attr]["type"]), "name": attr, }) a7 = prompt(q7, style=style) try: for i, j in a7.items(): a7[i] = convert(attrs[i]["type"], j) s = db.update(a2["table"], s1, **a7) puts(colored.green('Query "{}" executed successfully'.format(s))) except Exception as e: puts(colored.red(e)) elif a1["command"] == "Get": choices = [Separator("= {} =".format(a2["table"]))] attrs = db.schema_struct[a2["table"]] for i in attrs: choices.append({"name": i}) q4 = [{ "type": "checkbox", "message": "Select attributes you want to display", "name": "getattr", "choices": choices, }]
lambda text: len(text) != 0 or "Field can't be empty.", }] q5[0]["message"] = q5[0]["message"].format("bank name") a5 = prompt(q5, style=style) db.add_netbank(a1["userid"], a5["option"]) elif a2["option"] == "edit user details": a4 = prompt(q4, style=style) if a4["option"] != []: ans = [] for i in a4["option"]: q5 = [{ "type": "input", "message": "Enter {}", "name": "option", "validate": lambda text: len(text) != 0 or "Field can't be empty.", }] q5[0]["message"] = q5[0]["message"].format(i) a5 = prompt(q5, style=style) ans.append(a5["option"]) kwargs = dict([a4["option"], ans]) db.update("users", "userid='{}'".format(a1["userid"]), **kwargs) else: a6 = prompt(q6, style=style) if a6["option"]: db.delete("users", userid=a1["userid"])