All work on supply query and area.csv

This commit is contained in:
Matt McWilliams 2024-11-09 21:41:51 -05:00
parent 340e87dc22
commit 031beed099
5 changed files with 47 additions and 7 deletions

4
.gitignore vendored
View File

@ -1 +1,3 @@
developers.sqlite developers.sqlite
__pycache__
env

9
area.csv Normal file
View File

@ -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
1 Film Format Area (mm^2)
2 35mm x 36 exp 47880
3 35mm x 24 exp 31920
4 120 (std) 49200
5 120 (min) 45600
6 120 (max) 51000
7 4x5 12827
8 4x5 x 6 exp 76962
9 8x10 51612

28
area.py Normal file
View File

@ -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')

View File

@ -1,5 +1,3 @@
#!/bin/bash
import sqlite3 import sqlite3
import csv import csv
import os import os
@ -64,12 +62,15 @@ def displayCost (ml) :
for row in rows: for row in rows:
recipe = row[1] recipe = row[1]
print(f"{recipe}: {ml/1000} liters") 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 INNER JOIN supply AS s
ON c.chemical_id = s.chemical_id ON c.chemical_id = s.chemical_id
INNER JOIN chemicals AS a INNER JOIN chemicals AS a
ON c.chemical_id = a.chemical_id 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],)) cursor.execute(query, (row[0],))
components = cursor.fetchall() components = cursor.fetchall()
@ -118,4 +119,4 @@ print('----')
print('COST') print('COST')
print('----') print('----')
displayCost(3785) #gallon displayCost(125) #gallon

View File

@ -40,7 +40,7 @@ class Supply :
print(row) print(row)
def display (self, supply_id, chemical) : 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,)) res = self.cursor.execute(query, (supply_id,))
data = self.cursor.fetchone() data = self.cursor.fetchone()
ratio = data[0] ratio = data[0]