Beispiel #1
0
def db_crt():
    import mysql.connector as sq
    import time as t
    import authenticator
    auth_data = authenticator.read()
    uid = auth_data[0]
    password = auth_data[1]
    db = sq.connect(host='localhost', user=uid, passwd=password)
    cursor = db.cursor()
    print("Checking Database")
    check = 'show databases'
    cursor.execute(check)
    l = cursor.fetchall()
    l = [i[0] for i in l]
    if not 'farec' in l:
        qu = 'create database farec;'
        print("Database doesn't exist\nCreating database")
        cursor.execute(qu)
        print('Loading', end="")
        for i in range(0, 20):
            print(".", end="")
            t.sleep(0.01)
        db.commit()
        db.close()
    else:
        print("\nDatabase found!")
Beispiel #2
0
def tb_crt():
    import mysql.connector as sq
    import time as t
    import authenticator
    auth_data = authenticator.read()
    uid = auth_data[0]
    password = auth_data[1]
    tb = sq.connect(host='localhost',
                    user=uid,
                    passwd=password,
                    database='farec')
    crsr = tb.cursor()
    print("\nChecking Table")
    check2 = 'show tables'
    crsr.execute(check2)
    m = crsr.fetchall()
    m = [i[0] for i in m]
    if not 'record' in m:
        qu2 = 'create table record (roll int(11), name varchar(20), adm int(11), farec_id int(11) PRIMARY KEY);'
        print("Table doesn't exist\nCreating table")
        crsr.execute(qu2)
        print('Loading', end="")
        for i in range(0, 20):
            print(".", end="")
            t.sleep(0.01)
        print("\n")
        tb.commit()
        tb.close()
    else:
        print("\nTable found!\n------------\n")
Beispiel #3
0
def tb_upd():
    import mysql.connector as sq
    from datetime import datetime
    import authenticator
    auth_data = authenticator.read()
    uid = auth_data[0]
    password = auth_data[1]
    db=sq.connect(host='localhost',user=uid,passwd=password,database='farec')
    cursor=db.cursor()
    now=datetime.now()
    dt=now.strftime("%d_%m_%Y")
    qu="alter table record add "+dt+" varchar(3) default 'no';"
    cursor.execute(qu)
    cursor.close()
    db.close()
    print(dt)
    print("Done!")
Beispiel #4
0
    pyt = 'python3 '
print("Checking required modules")
os.system(
    shell +
    'pip3 install pillow numpy opencv-python opencv-contrib-python tabulate mysql-connector-python mysql-connector pyfiglet'
)
os.system(shell + clr)

import mysql.connector as sq
from tabulate import tabulate
import table_creator as tbc
import pyfiglet as fg
import authenticator

if authenticator.check() == True:
    auth_data = authenticator.read()
    uid = auth_data[0]
    password = auth_data[1]
elif authenticator.check() == False:
    authenticator.reg()

tbc.db_crt()
tbc.tb_crt()

db = sq.connect(host='localhost', user=uid, passwd=password, database='farec')
cursor = db.cursor()
tabulate.PRESERVE_WHITESPACE = True
os.system(shell + clr)
banner = fg.figlet_format("FaRec")

while True: