diff --git a/.gitignore b/.gitignore index f99050c..da573b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -developers.sqlite \ No newline at end of file +developers.sqlite +__pycache__ +env diff --git a/area.csv b/area.csv new file mode 100644 index 0000000..4a70e78 --- /dev/null +++ b/area.csv @@ -0,0 +1,9 @@ +Film Format,Area (mm^2) +35mm x 36 exp, 47880 +35mm x 24 exp, 31920 +120 (std), 49200 +120 (min), 45600 +120 (max), 51000 +4x5, 12827 +4x5 x 6 exp, 76962 +8x10, 51612 \ No newline at end of file diff --git a/area.py b/area.py new file mode 100644 index 0000000..4ad120d --- /dev/null +++ b/area.py @@ -0,0 +1,28 @@ +import sqlite3 +import csv +import os +from uuid import uuid4 +from os import path +from argparse import ArgumentParser + +parser = ArgumentParser() + +args = parser.parse_args() + +STANDARD_AREA=None +STANDARD_ML=100 + +AREA='./area.csv' + +with open(AREA, newline='') as csvfile: + reader = csv.reader(csvfile, delimiter=',', quotechar='|') + for row in reader: + if row[0] == 'Film Format' : + continue + name = row[0] + area = float(row[1].strip()) + if STANDARD_AREA is None : + STANDARD_AREA = area + ml = area * (STANDARD_ML / STANDARD_AREA) + print(f'{name} [{area}] = {ml}ml') + diff --git a/import.py b/import.py index 08002f1..4553821 100644 --- a/import.py +++ b/import.py @@ -1,5 +1,3 @@ -#!/bin/bash - import sqlite3 import csv import os @@ -64,12 +62,15 @@ def displayCost (ml) : for row in rows: recipe = row[1] print(f"{recipe}: {ml/1000} liters") - query = """SELECT a.name, (c.grams * (s.price/s.grams)) / c.makes, (c.grams/c.makes) FROM components AS c + query = """SELECT a.name AS name, (c.grams * (s.price/s.grams)) / c.makes AS cost, (c.grams/c.makes) FROM components AS c INNER JOIN supply AS s ON c.chemical_id = s.chemical_id INNER JOIN chemicals AS a ON c.chemical_id = a.chemical_id - WHERE c.recipe_id = ?;""" + WHERE c.recipe_id = ? + GROUP BY name + ORDER BY cost ASC; + """ cursor.execute(query, (row[0],)) components = cursor.fetchall() @@ -118,4 +119,4 @@ print('----') print('COST') print('----') -displayCost(3785) #gallon +displayCost(125) #gallon diff --git a/supply.py b/supply.py index 0098631..621c31e 100644 --- a/supply.py +++ b/supply.py @@ -40,7 +40,7 @@ class Supply : print(row) def display (self, supply_id, chemical) : - query="SELECT round((price/100.0)/grams, 2) as ppg FROM supply WHERE (supply_id = ?) ORDER BY ppg ASC;" + query="SELECT round((price/100.0)/grams, 2) as ppg FROM supply WHERE (supply_id = ?);" # ORDER BY ppg ASC res = self.cursor.execute(query, (supply_id,)) data = self.cursor.fetchone() ratio = data[0]