本文整理汇总了Python中models.Exercise.insert方法的典型用法代码示例。如果您正苦于以下问题:Python Exercise.insert方法的具体用法?Python Exercise.insert怎么用?Python Exercise.insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Exercise
的用法示例。
在下文中一共展示了Exercise.insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: str
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import insert [as 别名]
print exercise
elif sys.argv[1] == 'insert':
if sys.argv[2] == 'school':
school = School.insert(name=sys.argv[3]).execute()
print "New school: " + str(School.select().where(School.id==school).get())
elif sys.argv[2] == 'batch':
batch = Batch.insert(school=sys.argv[3], name=sys.argv[4]).execute()
print "New batch: " + str(Batch.select().where(Batch.id==batch).get())
elif sys.argv[2] == 'student':
if len(sys.argv) == 6:
student = Student.insert(batch=sys.argv[3], age=sys.argv[4], last_name='', first_name=sys.argv[5]).execute()
else:
student = Student.insert(batch=sys.argv[3], age=sys.argv[4], last_name=sys.argv[5], first_name=sys.argv[6]).execute()
print "New student: " + str(Student.select().where(Student.id==student).get())
elif sys.argv[2] == 'exercise':
exercise = Exercise.insert(student=sys.argv[3], subject=sys.argv[4],note=sys.argv[5]).execute()
print "New exercise: " + str(Exercise.select().where(Exercise.id==exercise).get())
elif sys.argv[1] == 'delete':
if sys.argv[2] == 'school':
if School.select().where(School.id==sys.argv[3]).count() == 0:
print "Nothing to delete"
else:
print_school = "Delete: " + str(School.select().where(School.id==sys.argv[3]).get())
school = School.delete().where(School.id == sys.argv[3]).execute()
print print_school
elif sys.argv[2] == 'student':
if Student.select().where(Student.id==sys.argv[3]).count() == 0:
print "Nothing to delete"
else:
print_student = "Delete: " + str(Student.select().where(Student.id==sys.argv[3]).get())
student = Student.delete().where(Student.id == sys.argv[3]).execute()