def run_select_name():
    run_sql_script(SELECT_NAME_SQL)
    rows = CURSOR.fetchall()
    att = attr_name()
    for row in rows:
        for i, element in enumerate(att):
            print("%s: %s" % (element, row[i])) 
        print("\n")
    print("Total members %d" % len(rows))
    def __init__(self, first_name, last_name):
        self.first_name = first_name
        self.last_name = last_name

        self.member_id = []
        run_sql_script(VIEW_MEMBER_SQL, (self.first_name, self.last_name))
        self.members = CURSOR.fetchall()

        for member in self.members:
            self.member_id.append(member[0])
def run_del(id_to_del):
    run_sql_script(DELETE_ID_SQL, (id_to_del))
    rows = CURSOR.fetchall()
def run_view(first_name, last_name):
    run_sql_script(VIEW_MEMBER_SQL, (first_name, last_name))
    rows = CURSOR.fetchall()
    get_attributes(rows, attributes())
def run_select_all():
    run_sql_script(SELECT_ALL_SQL)
    rows = CURSOR.fetchall()
    get_attributes(rows, attributes())
def run_sql_script(filename, *args):
    """ execute sql files """
    file = open(filename, 'r')
    sql_file = file.read()
    file.close()
    CURSOR.execute(sql_file, *args)
Exemple #7
0
from definitions import CONNECTION, CURSOR
from definitions import CREATE_EMPLOYEES, INSERT_EMPLOYEES

def read_sql_script(sql_file, *args)
    f = open('sql_scripts/create.sql', 'r')
    sql_file = f.read()
    f.close()
    CURSOR.execute(sql_file, *args)