from mydb import Db
import pymysql
import cgi
# # import pymysql
form = cgi.FieldStorage()
tableName = 'note'
print("Content-type: text/html; charset=utf-8\n")

db = Db()
id_cours = form.getvalue("id_cours")
listNoteTrieeHtml = ''
courSelectionneeHtml = ''

if str(id_cours) != "None":

    e = db.getOneQuery(f"select * from cours where id = {id_cours}")

    courSelectionneeHtml += f'Note triee du cour {e[1]} ({e[2]}): <br>'

    listNoteTriee = db.getQuery(f"""
    select e.nom, e.prenom, e.age, note
    from note n
        INNER JOIN etudiant e on n.id_etudiant = e.id
    where id_cours = {id_cours}
    order by note desc
    """)

    for e in listNoteTriee:
        listNoteTrieeHtml += f"- {e[0]} {e[1]} ({e[2]} ans): {e[3]}<br>"

listCours = db.getQuery(f'select * from Cours')
from mydb import Db
import pymysql
import cgi

form = cgi.FieldStorage()
print("Content-type: text/html; charset=utf-8\n")


db = Db()
id_cours = form.getvalue("id_cours")
msg = ''

if str(id_cours) != "None":

    e = db.getOneQuery(f"select * from cours where id = {id_cours}")

    db.updateQuery(f"delete from note where id_cours = {id_cours}")

    db.updateQuery(f"delete from cours where id = {id_cours}")
    
    msg = f'Le cours {e[1]} ({e[2]}) et les notes associees ont ete supprimes'

# get all
listCours = db.getQuery(f'select * from Cours')
listCoursHtml = ''

for e in listCours:
    listCoursHtml += f'{e[0]}. {e[1]} ({e[2]})<br>'


from mydb import Db
import pymysql
import cgi
# # import pymysql
form = cgi.FieldStorage()
tableName = 'note'
print("Content-type: text/html; charset=utf-8\n")

db = Db()
id_etudiant = form.getvalue("id_etudiant")
listNotePourEtudiantHtml = ''
etudiantSelectionne = []
if str(id_etudiant) != "None":

    e = db.getOneQuery(f"select * from etudiant where id = {id_etudiant}")

    listNotePourEtudiantHtml += f'Note de {e[1]} {e[2]} ({e[3]} ans): <br>'

    listNote = db.getQuery(f"""
    select c.intitule, c.annee, note
    from note n
        INNER JOIN etudiant e on n.id_etudiant = e.id
        INNER JOIN cours c on n.id_cours = c.id
    where id_etudiant = {id_etudiant}
    """)

    for e in listNote:
        listNotePourEtudiantHtml += f"- {e[0]} ({e[1]}): {e[2]}<br>"

# get all
listEtudiant = db.getQuery(f'select * from Etudiant')
Beispiel #4
0
noteSql = f"""
create table if not EXISTS Note(
    id int primary key auto_increment,
    id_etudiant int not null,
    id_cours int not null,
    note int not null,
    FOREIGN KEY (id_etudiant) REFERENCES Etudiant(id),
    FOREIGN KEY (id_cours) REFERENCES Cours(id)
);
"""
navbar = open('navbar.html', '+r').read()

print(navbar)

db = Db()

# 2 - create
# db.updateDataBase(f'DROP DATABASE IF EXISTS {Config.db};')
db.updateDataBase(f'create database if not EXISTS {Config.db};')
db.updateDataBase(f'use {Config.db};')
print(f'database {Config.db} created successfully<br>')

# 1- drop if existe

db.updateTable('DROP TABLE IF EXISTS note')
db.updateTable('DROP TABLE IF EXISTS etudiant')
db.updateTable('DROP TABLE IF EXISTS cours')

db.updateTable(etudiantSql)
print('Table etudiant created successfully<br>')
from mydb import Db
import pymysql
import cgi

form = cgi.FieldStorage()
tableName = 'etudiant'
print("Content-type: text/html; charset=utf-8\n")

db = Db()
prenom = form.getvalue("prenom")
nom = form.getvalue("nom")
age = form.getvalue("age")

# add record
if str(prenom) != "None" and str(nom) != "None" and str(age) != "None":
    db.updateQuery(
        f"insert into {tableName} values (null, '{nom}', '{prenom}', '{age}')")

# get all
list = db.getQuery(f'select * from {tableName}')

listHtml = ''
for row in list:
    listHtml += f'nom : {row[1]}, prenom {row[2]}, age {row[3]} <br>'

navbar = open('navbar.html', '+r').read()

html = f"""<!DOCTYPE html>
<head>
    <title>Groupf</title>
</head>
from mydb import Db
import pymysql
import cgi
# # import pymysql
form = cgi.FieldStorage()
print("Content-type: text/html; charset=utf-8\n")

db = Db()
tableName = 'note'
note = form.getvalue("note")
id_etudiant = form.getvalue("id_etudiant")
id_cours = form.getvalue("id_cours")

# add record
if str(note) != "None" and str(id_etudiant) != "None" and str(
        id_cours) != "None":
    db.updateQuery(
        f"insert into {tableName} values (null, '{id_etudiant}', '{id_cours}', '{note}')"
    )

# get all
listEtudiant = db.getQuery(f'select * from Etudiant')
listEtudiantHtml = ''
for e in listEtudiant:
    listEtudiantHtml += f'{e[0]}. {e[1]} {e[2]} ({e[2]})<br>'

listCours = db.getQuery(f'select * from Cours')
listCoursHtml = ''
for e in listCours:
    listCoursHtml += f'{e[0]}. {e[1]} ({e[2]})<br>'
from mydb import Db
import pymysql
import cgi

form = cgi.FieldStorage()
print("Content-type: text/html; charset=utf-8\n")

db = Db()
tableName = 'cours'
intitule = form.getvalue("intitule")
annee = form.getvalue("annee")

if str(intitule) != "None" and str(annee) != "None":
    r = db.updateQuery(
        f"insert into {tableName} values (null, '{intitule}', '{annee}')")

# get all
list = db.getQuery(f'select * from {tableName}')

listHtml = ''
for row in list:
    listHtml += f'intitule : {row[1]}, annee {row[2]} <br>'

navbar = open('navbar.html', '+r').read()

html = f"""<!DOCTYPE html>
<head>
    <title>Groupf</title>
</head>
<body>
    {navbar}