Esempio n. 1
0
def insertStudents(request):
    print("This is the insert Excel page")
    connection = sqlite3.connect('students.db')
    cursor = connection.cursor()
    if request.method == "POST":
        data = request.POST.copy()
        student=Student()
        student.room_no = data.get('room_no')
        student.block = data.get('block')
        student.name = data.get('name')
        student.mob_no = data.get('mob_no')
        student.id_no = data.get('id_no')
        print(student.room_no)
        student.save()
        #sql_insert_single = "INSERT INTO students(ROOMNO, BLOCK, STUDENT, MOBILE, ID) VALUES('{0}', '{1}', '{2}', '{3}', '{4}')".format(room_no, block, student, mobile, id)
        #cursor.execute(sql_insert_single)
        connection.commit()
        connection.close()
    return render(request, 'insertStudentExcel.html')