import cgi
from classes.pythonSqlConnect import PythonSqlConnect
form = cgi.FieldStorage()
#print(form.getvalue("name"))

# Encoding
import sys
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
print("Content-type: text/html; charset=utf-8\n")

# Query and Fetch the students
con = PythonSqlConnect()
students = con.getAllStudents()

html = """<!DOCTYPE html>
<head>
    <title>Afficher les notes d'un étudiant</title>
</head>
<body>
    <form action="validation3.py" method="post">
        <p>Liste des étudiants : </p>
        <ul>
"""
for student in students:
    html += "<li>{} {} {}</li>".format(student[0], student[1], student[2],
                                       student[3])

html += """
        </ul>
        <label>Votre choix :
            <input type="number" name="etudiantChoice" value="" placeholder="Quel étudiant?" />
Ejemplo n.º 2
0
# From folder classes in the module pythonSqlConnect import the Class PythonSqlConnect
from classes.pythonSqlConnect import PythonSqlConnect

header = """<!DOCTYPE html>
<head>
    <head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></head>
    <title>Mon programme</title>
</head>
<body>
"""
print(header)

try:
    # Create Database
    con = PythonSqlConnect(PythonSqlConnect.emptyDb)
    con.createDatabase(PythonSqlConnect.databaseName)
    
    # Create tables
    con = PythonSqlConnect()
    con.createTables()

    # # Populate the tables
    con.populateStudent("Mark", "Zuckerberg", 34)
    con.populateStudent("Bill", "Gates", 63)
    con.populateCourse("Deep Learning", 2018)
    con.populateCourse("Python", 2010)

    con.addNote("Mark", "Zuckerberg", "Deep Learning", 15)
    con.addNote("Bill", "Gates", "Python", 14)
    con.addNote("Mark", "Zuckerberg", "Python", 17)
Ejemplo n.º 3
0
import sys
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering = 1)
print("Content-type: text/html; charset=utf-8\n")

from classes.pythonSqlConnect import PythonSqlConnect

html = """<!DOCTYPE html>
<head>
    <title>Mon programme</title>
</head>
</body>
"""
print(html)

# Values get from the form
courseChoice = form.getvalue("courseChoice")

try:
    con = PythonSqlConnect()
    con.deleteCourse(courseChoice)
    # print(con.getStudentById(etudiantChoice))

except Exception as e:
    print("Exception occured:{}".format(e))

finally:
    #disconnect from server
    # con.closeCon()

    print("<a href='../index.py'>Retour au menu principal</a>")
Ejemplo n.º 4
0
import cgi
form = cgi.FieldStorage()
from classes.pythonSqlConnect import PythonSqlConnect

#print(form.getvalue("name"))

# Encoding
import sys
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
print("Content-type: text/html; charset=utf-8\n")

# Query and Fetch the students
con = PythonSqlConnect()
courses = con.getAllCourses()

html = """<!DOCTYPE html>
<head>
    <title>supprimer un cours et les notes associées</title>
</head>
<body>
    <form action="validation5.py" method="post">
        <p>Liste des cours : </p>
        <ul>
"""
for course in courses:
    html += "<li>{} - {} ({})</li>".format(course[0], course[1], course[2])

html += """
        </ul>
        <label>Votre choix :
            <input type="number" name="courseChoice" value="" placeholder="Quel cours?" />
Ejemplo n.º 5
0
import sys
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
print("Content-type: text/html; charset=utf-8\n")

from classes.pythonSqlConnect import PythonSqlConnect

html = """<!DOCTYPE html>
<head>
    <title>Mon programme</title>
</head>
</body>
"""
print(html)

# Values get from the form
etudiantChoice = form.getvalue("etudiantChoice")

try:
    con = PythonSqlConnect()
    con.deleteCourse(etudiantChoice)
    # print(con.getStudentById(etudiantChoice))

except Exception as e:
    print("Exception occured:{}".format(e))

finally:
    #disconnect from server
    # con.closeCon()

    print("<a href='../index.py'>Retour au menu principal</a>")
Ejemplo n.º 6
0
import cgi
from classes.pythonSqlConnect import PythonSqlConnect

form = cgi.FieldStorage()
#print(form.getvalue("name"))

# Encoding
import sys

# Query and Fetch the students
con = PythonSqlConnect()
students = con.getAllStudents()
courses = con.getAllCourses()

sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
print("Content-type: text/html; charset=utf-8\n")

html = """<!DOCTYPE html>
<head>
    <title>Mon programme</title>
</head>
<body>
    <form action="validation2.py" method="post">
        <label>Note à attribuer :
            <input type="number" name="note" value="" placeholder="Note" />
        </label><br>
        <p>Liste des étudiants : </p>
        <ul>
"""

for student in students:
Ejemplo n.º 7
0
import sys
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
print("Content-type: text/html; charset=utf-8\n")

from classes.pythonSqlConnect import PythonSqlConnect

html = """<!DOCTYPE html>
<head>
    <title>Mon programme</title>
</head>
</body>
"""
print(html)

# Values get from the form
etudiantChoice = form.getvalue("etudiantChoice")

try:
    con = PythonSqlConnect()
    con.displayNotesForStudent(etudiantChoice)
    # print(con.getStudentById(etudiantChoice))

except Exception as e:
    print("Exception occured:{}".format(e))

finally:
    #disconnect from server
    # con.closeCon()

    print("<a href='../index.py'>Retour au menu principal</a>")
Ejemplo n.º 8
0
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
print("Content-type: text/html; charset=utf-8\n")

from classes.pythonSqlConnect import PythonSqlConnect

html = """<!DOCTYPE html>
<head>
    <title>Mon programme</title>
</head>
</body>
"""
print(html)

# Values get from the form
firstName = form.getvalue("firstName")
lastName = form.getvalue("lastName")
age = form.getvalue("age")

try:
    con = PythonSqlConnect()
    con.populateStudent(firstName, lastName, age)

except Exception as e:
    print("Exception occured:{}".format(e))

finally:
    #disconnect from server
    con.closeCon()

    print("<a href='../index.py'>Retour au menu principal</a>")