Exemple #1
0
import db
import log_main
import logging
import traceback

log_main.initialize_logger("Employee")


def insert_data():
    try:
        query = "INSERT INTO EMPLOYEE (Fname, Minit, Lname, SSN, Birth_date, Address, Sex, Salary, Department) " \
                "VALUE (%s, %s, %s, %s, STR_TO_DATE(%s,'%d-%b-%Y'), %s, %s, %s, %s)"

        # 1
        data = ('James', 'E', 'Jordan', '888665151', '10-NOV-1927',
                '450 Stone,Houston,TX', 'M', 55000, 1)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 2
        data = ('Frank', 'T', 'Wong', '333445555', '08-DEC-1945',
                '638 Voss,Houston,TX', 'M', 40000, 5)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 3
        data = ('Jennifer', 'S', 'Wallace', '987654321', '20-JUN-1931',
                '291 Berry,Bellaire,TX', 'F', 43000, 4)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))
Exemple #2
0
import db
import logging
import traceback
import log_main

log_main.initialize_logger("Q3")


def q3_1():
    try:
        query = "SELECT * FROM EMPLOYEE WHERE Lname='Jones' OR Lname='James'"

        result = db.read_query(query)
        print(result)
        logging.info('Query: ' + str(query) + '\nResult: ' + str(result))

    except Exception as e:
        traceback.print_exc()
        logging.error('Error in SELECT_DATA: %s', e)


def q3_2():
    try:
        query = "SELECT * FROM EMPLOYEE WHERE Fname='Kim' OR Fname='Wilson'"

        result = db.read_query(query)
        print(result)
        logging.info('Query: ' + str(query) + '\nResult: ' + str(result))

    except Exception as e:
        traceback.print_exc()
Exemple #3
0
import db
import log_main
import logging
import traceback

log_main.initialize_logger("Works_On")


def insert_data():
    try:
        query = "INSERT INTO WORKS_ON (Essn, Pno, Hours) VALUES (%s, %s, %s)"

        # 1
        data = ('123456789', 5, 32.5)
        print(db.insert_query(query, data))
        logging.info(str(query) + " " + str(data))

        # 2
        data = ('123456789', 6, 7.5)
        print(db.insert_query(query, data))
        logging.info(str(query) + " " + str(data))

        # 3
        data = ('666884444', 7, 40.0)
        print(db.insert_query(query, data))
        logging.info(str(query) + " " + str(data))

        # 4
        data = ('453453453', 5, 20.0)
        print(db.insert_query(query, data))
        logging.info(str(query) + " " + str(data))
Exemple #4
0
import db
import log_main
import logging
import traceback

log_main.initialize_logger("Project")


def insert_data():
    try:
        query = "INSERT INTO PROJECT (Pname, Pnumber, Plocation, Controlling_department) VALUES (%s, %s, %s, %s)"

        # 1
        data = ('EntityAnnot', 4, 'Houston', 5)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 2
        data = ('Analysis', 5, 'Sacramento', 6)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 3
        data = ('EventManagement', 6, 'Sacramento', 6)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 4
        data = ('FoodDistribution', 7, 'Sacramento', 6)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))
Exemple #5
0
import db
import log_main
import logging
import traceback

log_main.initialize_logger("Dept_Locations")


def insert_data():
    try:
        query = "INSERT INTO DEPT_LOCATIONS (Dnumber, Dlocation) VALUES (%s, %s)"

        # 1
        data = (1, 'Houston')
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 2
        data = (4, 'Stafford')
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 3
        data = (5, 'Bellaire')
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 4
        data = (5, 'Sugarland')
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))
Exemple #6
0
import db
import log_main
import logging
import traceback

log_main.initialize_logger("Dependent")


def insert_data():
    try:
        query = "INSERT INTO DEPENDENT (Essn, Dependent_name, Sex, Birth_date, Relationship) " \
                "VALUES (%s, %s, %s, STR_TO_DATE(%s,'%d-%b-%Y'), %s)"

        # 1
        data = ('888665151', 'Mary Alice', 'F', '10-NOV-1924', 'Spouse')
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 2
        data = ('444444400', 'Kathy', 'F', '09-OCT-1944', 'Spouse')
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 3
        data = ('999887777', 'John Smith', 'M', '19-JUL-1956', 'Spouse')
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 4
        data = ('987987987', 'Khadeja Begum', 'F', '29-MAR-1949', 'Spouse')
        print(db.insert_query(query, data))
Exemple #7
0
import db
import log_main
import logging
import traceback

log_main.initialize_logger("Department")


def insert_data():
    try:
        query = "INSERT INTO DEPARTMENT (Dname, Dnumber) VALUES (%s, %s)"

        # 1
        data = ('Research', 5)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 2
        data = ('Administration', 4)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 3
        data = ('Headquarters', 1)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))

        # 4
        data = ('Software', 6)
        print(db.insert_query(query, data))
        logging.info(str(query) + ' ' + str(data))