Skip to content

Instantly share code, notes, and snippets.

@Anas-jaf
Last active May 22, 2021 18:45
Show Gist options
  • Save Anas-jaf/92f0cda008a9444bdff9e20946e24efa to your computer and use it in GitHub Desktop.
Save Anas-jaf/92f0cda008a9444bdff9e20946e24efa to your computer and use it in GitHub Desktop.
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
database="fuad_project"
)
def sort_stu () :
mycursor = mydb.cursor()
mycursor.execute("SELECT avg,sec FROM request")
myresult = mycursor.fetchall()
for x in myresult:
# string = ','.join(map(str, x))
# هذا الكود للعلامة
if x[0] != None:
# هذا الكود للتخصص
if x[1] == "علمي":
print(x)
mycursor2 = mydb.cursor()
mycursor2.execute("SELECT spec FROM majors where min <= %s" % x[0])
myresult2 = mycursor.fetchall()
for z in myresult2:
print(''.join(map(str, z)))
print("=====================================")
else:
# اذا مش علمي
print(x)
mycursor2 = mydb.cursor()
mycursor2.execute("SELECT spec FROM majors where min <= %s and id_m not BETWEEN 302 and 432 and id_m not between 1101 and 1104 and id_m not between 2201 and 2203 and id_m != 1703 " % x[0])
myresult2 = mycursor.fetchall()
for z in myresult2:
print(''.join(map(str, z)))
print("=====================================")
def fath_job ():
mycursor3 = mydb.cursor()
mycursor3.execute("SELECT jop_sec FROM request")
myresult = mycursor3.fetchall()
administrator=0
teachers=0
for x in myresult:
if x[0] == "إداري":
administrator +=1
else :
teacher+=1
print("number of administrators is "+str(administrator)+" and number of teachers is "+str(teachers ))
sort_stu()
fath_job()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment