class Details(Resource): try: Student.create_table(); except Exception as e: print(e); def get(self,name): try: employee_details = {} details = Student.get_data(name); for i in details: employee_details['id'] = i[0]; employee_details['name'] = i[1]; return employee_details,200 except Exception as e: print(e); def delete(self,name): Student.delete_data(name); return {"Status":"Record Removed"},200 def post(self,name): try: data = request.get_json(); id_list = (data['id']) name_list = data['name']; my_tup = list(zip(id_list,name_list)) print(my_tup) z = Student.insert_data(my_tup); return {"Status":"Data_Inserted","data":z},201 except Exception as e: print(e);
def create_table_test(): Teacher.create_table() Student.create_table()
School.create_table() except peewee.OperationError: pass try: Batch.create_table() except peewee.OperationError: pass try: User.create_table() except peewee.OperationError: pass try: Student.create_table() except peewee.OperationError: pass try: Exercise.create_table() except peewee.OperationError: pass elif sys.argv[1] == 'print': if len(sys.argv) >= 3: if sys.argv[2] == 'school': for school in School.select(): print school elif sys.argv[2] == 'batch': for batch in Batch.select(): print batch elif sys.argv[2] == 'user':
School.create_table() except peewee.OpertationalError: pass try: Batch.create_table() except peewee.OpertationalError: pass try: User.create_table() except peewee.OpertationalError: pass try: Student.create_table() except peewee.OpertationalError: pass if sys.argv[2] == : School.create(name= argv[3]) print New school: School: self.name, self.id elif: argv[2] == "batch" Batch.create(school= array[3], name= argv[4]) print New batch: Batch: self.school, self.name elif: argv[2] == "user" User.create(first_name = argv[3], last_name = argv[4], age = argv[5])