def parse(config_file): repo.create_tables() with open(config_file) as file: amounts = file.readline() amounts.strip() vaccinesBulk = int(amounts[0]) suppliersAmount = int(amounts[2]) clinicsAmount = int(amounts[4]) logisticsAmount = int(amounts[6]) for i in range(0, vaccinesBulk): line = file.readline() line = line.split(",") vac = Vaccine.Vaccine(int(line[0]), line[1], int(line[2]), int(line[3])) repo.Vaccines.insert(vac) for i in range(vaccinesBulk, vaccinesBulk + suppliersAmount): line = file.readline() line = line.split(",") sup = Supplier.Supplier(int(line[0]), line[1], int(line[2])) repo.Suppliers.insert(sup) # Dao.Dao.insert(sup,Supplier) for i in range(suppliersAmount, suppliersAmount + clinicsAmount): line = file.readline() line = line.split(",") clinc = Clinic.Clinic(int(line[0]), line[1], int(line[2]), int(line[3])) repo.Clinics.insert(clinc) for i in range(clinicsAmount, clinicsAmount + logisticsAmount): line = file.readline() line = line.split(",") logi = Logistic.Logistic(int(line[0]), line[1], int(line[2]), int(line[3])) repo.Logistics.insert(logi)
def main(): if not os.path.isfile( 'schedule.db' ): # First time creating the database. Create the tables from Repository import repo repo.create_tables() config_file = open(sys.argv[1], 'r') for line in config_file: fields = line.split(',') if (fields[0].strip().__eq__('S')): student = DTO.Student(fields[1].strip(), fields[2].strip()) repo.students.insert(student) elif (fields[0].strip().__eq__('R')): classroom = DTO.Classroom(fields[1].strip(), fields[2].strip(), 0, 0) repo.classrooms.insert(classroom) else: course = DTO.Course(fields[1].strip(), fields[2].strip(), fields[3].strip(), int(fields[4].strip()), int(fields[5].strip()), int(fields[6].strip())) repo.courses.insert(course) config_file.close() repo.print_all()
def main(args): # imports import os # delete DataBase if exists if os.path.exists('moncafe.db'): os.remove('moncafe.db') from Repository import repo repo.create_tables() from DTO import Employee, Coffee_stand, Product, Supplier # with open('config.txt') as inputFile: # for line in inputFile: # print(line) inputfilename = args[1] with open(inputfilename) as inputfile: for line in inputfile: words = line.split(",") if words[0] == 'C': repo.coffee_stands.insert( Coffee_stand(words[1].strip(' '), words[2].strip(' '), words[3].strip(' '))) if words[0] == 'S': repo.suppliers.insert( Supplier(words[1].strip(' '), words[2].strip(' '), words[3][:-1].strip(' '))) if words[0] == 'E': repo.employees.insert( Employee(words[1].strip(' '), words[2].strip(' '), words[3].strip(' '), words[4].strip(' '))) if words[0] == 'P': repo.products.insert( Product(words[1].strip(' '), words[2].strip(' '), words[3].strip(' '), 0))
def main(args): repo.create_tables() inputfilename = args[1] with open(inputfilename) as inputfile: for line in inputfile: line = line.strip('\n') args = line.split(', ') orginal2= args[2] orginal3 = args[3] args[1] = str(args[1]).replace(" ", "") args[2] = str(args[2]).replace(" ", "") args[3] = str(args[3]).replace(" ", "") if args[0] == "C": currCoffee_stand = Coffee_stand(args[1], "'{}'".format(args[2]), args[3]) repo.coffee_stands.insert(currCoffee_stand) if args[0] == "S": args[3] = orginal3 currSupplier = Supplier(args[1],"'{}'".format(args[2]),"'{}'".format(args[3])) repo.suppliers.insert(currSupplier) if args[0] == "E": args[4] = str(args[4]).replace(" ", "") currEmployee = Employee(args[1],args[2],args[3],args[4]) repo.employees.insert(currEmployee) if args[0] == "P": args[2]=orginal2 currProduct = Product(args[1], "'{}'".format(args[2]), args[3], 0) repo.products.insert(currProduct)
def main(config_file, order_file, output_file): cursor = repo._dbcon.cursor() repo.create_tables() config = repo.read_insert(config_file) orders = repo.read_orders_file(order_file, output_file) print(config) print(orders)
def main(): repo.create_tables() create_database() f = open(sys.argv[2], "r") f2 = open(sys.argv[3], "w") for line in f: line = line.rstrip() lst = line[0:].split(',') if lst[0] in locations: send_shipment(lst) else: receive_shipment(lst) write(f2)
def main(): repo.create_tables() # extract all the information from the config file extract_from_config(sys.argv[1]) output = open(sys.argv[3], "w") with open(sys.argv[2]) as orders: for line in orders: order = line.split(",") if len(order) == 2: repo.send_shipment(*order) output.write(repo.get_total_summary()) output.flush() else: repo.receive_shipment(*order) output.write(repo.get_total_summary()) output.flush() output.close()
line = line[:-1] line_list = line.split(',') if not init: # get number of records for each table vaccines_num = int(line_list[0]) suppliers_num = int(line_list[1]) clinics_num = int(line_list[2]) logistics_num = int(line_list[3]) init = True elif vaccines_num > 0: # insert all the vaccines vaccine = Vaccine(*line_list) repo.vaccines.insert(vaccine) vaccines_num -= 1 elif suppliers_num > 0: # insert all the suppliers supplier = Supplier(*line_list) repo.suppliers.insert(supplier) suppliers_num -= 1 elif clinics_num > 0: # insert all the clinics clinic = Clinic(*line_list) repo.clinics.insert(clinic) clinics_num -= 1 elif logistics_num > 0: # insert all the logistics logistic = Logistic(*line_list) repo.logistics.insert(logistic) logistics_num -= 1 if __name__ == '__main__': repo.create_tables() parse_config() execute_commands()
def main(args): repo.create_tables() insert_data(args)
def main(args): repo.create_tables() insert_data(repo, args[1]) execute(repo, args[2], args[3])
def main(argv): repo.deleteifExist() repo.create_tables() load_configuration()