def main(cursor, a):
    import front as frnts
    import show_tables as st
    import attendance as atd
    import cr_table as crt
    import del_table as delt
    import data_entry as datae
    import show_attendance as shwatd
    import update_attendance as updatd
    import front as frnts
    import os
    #os.system("clear")

    if a == 1:
        atd.attendance(cursor)
    elif a == 2:
        crt.cr_table(cursor)
    elif a == 3:
        datae.entry(cursor)
    elif a == 4:
        delt.delete(cursor)
    elif a == 5:
        shwatd.show(cursor)
    elif a == 6:
        updatd.update(cursor)
    elif a == 7:
        st.show_table(cursor)
    elif a == 8:
        exit()
    else:
        frnts.front()
Beispiel #2
0
def cr_table(cursor):
    import front as frnts
    a = input("Enter the name of the classroom to create:")

    cursor.execute(
        "CREATE TABLE %s (name varchar(40), totalattendance varchar(5) );" % a)
    print("The %s classroom table has been created." % a)
    cursor.execute("COMMIT WORK;")

    condtn = input("*****Press any number to return to the main menu*****")
    if condtn == 1:
        exit()
    else:
        frnts.front(cursor)
Beispiel #3
0
def delete(cursor):
	import front as frnts
	a = str(input("Enter the name of class room to delete:"))


	cursor.execute("DROP TABLE %s ;" %a)
	print("The %s class room table has been deleted." %a)
	cursor.execute("COMMIT WORK;")


	condtn = input("*****Press any number to return to the main menu*****")
	if condtn == 1:
		exit()
	else :
		frnts.front(cursor)
def update(cursor):
    b = 0
    import front as frnts
    a = str(input("Enter the class room name to be updated:"))
    cursor.execute("SELECT * FROM %s;" % a)
    result = cursor.fetchall()
    #de = result[2]
    #print(de[0])
    for row in result:
        print(row[0], row[1])

    de = str(input("Enter the name of student to change attendance:"))
    #df = int(input("Enter the attendance to be updated of %s :" %de))
    lp = int(
        input(
            "Enter \n1. To increase attendance by 1 \n 2. To decrease attendance by 1:"
        ))
    if lp == 1:
        cursor.execute(
            "UPDATE " + a +
            " SET totalattendance=totalattendance+1 WHERE name = '%s';" %
            de[0])
        cursor.execute("COMMIT WORK;")
        print("Attendance has been incresed by ones")
    elif lp == 2:
        cursor.execute(
            "UPDATE " + a +
            " SET totalattendance=totalattendance-1 WHERE name = '%s';" %
            de[0])
        cursor.execute("COMMIT WORK;")
        print("Attendance has been decreased by one")
    else:
        print("\n****Invalid input****")

    cursor.execute("COMMIT WORK;")
    condtn = input("*****Press any number to return to the main menu*****")
    if b == 1:
        exit()
    else:
        frnts.front(cursor)
def show_table(cursor):
    import front as frnts
    cursor.execute("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'")
    result = cursor.fetchall()

    print("**** Tables present in Database ****\n")

    a= len(result) - 121

    for i in range(0,a):
        print(result[i],end=" ")
        print("\n")

    condtn = 0


    cursor.execute("COMMIT WORK;")
    condtn = int(input("*****Press any number to return to the main menu*****"))
    if condtn == 1:
        exit()
    else :
        frnts.front(cursor)
def attendance(cursor):
    condtn = 0
    import front as frnts
    c = str(input("Enter the class name to take attendance from:"))
    cursor.execute("SELECT * FROM %s;" %c)

    result = cursor.fetchall()

    a = len(result)

    while a>0 :
        de = result[(a-1)]
        b = int(input("Is "+de[0]+" present? 1. Yes 2. No"))

        if b==1 :
            cursor.execute("UPDATE "+c+" SET totalattendance=totalattendance+1 WHERE name = '%s';" %de[0])
        a=a-1

    cursor.execute("COMMIT WORK;")
    condtn = input("*****Press any number to return to the main menu*****")
    if condtn == 1:
        exit()
    else :
        frnts.front(cursor)
Beispiel #7
0
def getText():
    log1 = text.get(1.0, END)
    log2 = text2.get(1.0, END)
    try:
        '''Подключаем mysql
        Входные данные: -
        Выходные данные: -
        '''
        mydb = mysql.connector.connect(
            auth_plugin='mysql_native_password',
            user=log1[:-1],
            password=log2[:-1],
        )
        '''Создаём бд'''
        mycursor = mydb.cursor()
        all_dbfs = "all_in_one"
        database = "CREATE DATABASE IF NOT EXISTS " + all_dbfs
        mycursor.execute(database)

        if front.front(log1, log2):
            rt.quit()

    except mysql.connector.errors.ProgrammingError:
        messagebox.showinfo("Нотификация", "Неправильные данные")
#!/usr/bin/python


import MySQLdb
import front as frnts
# Open database connection
db = MySQLdb.connect("localhost","samir","sk","attendance" )

# prepare a cursor object using cursor() method
cursor = db.cursor()



frnts.front(cursor)



# execute SQL query using execute() method.
#cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method.
#data = cursor.fetchone()
#print ("Database version : %s " % data)

# disconnect from server
db.close()