partsdb

electronic parts inventory
git clone https://git.e1e0.net/partsdb.git
Log | Files | Refs

commit df0c1ce81abc948b05d2d1c8f16ad321fa4501e9
parent 25b341a8f190c104b95bd8353ed7f80a58b2af4f
Author: Paco Esteban <paco@e1e0.net>
Date:   Sun, 14 Mar 2021 13:25:23 +0100

add specs from octopart api

Diffstat:
Mdatabase.py | 3++-
Mhelpers.py | 1+
MmyChips.py | 5+++++
Mschema.sql | 1+
4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/database.py b/database.py @@ -30,6 +30,7 @@ INSERT_PART_QUERY = """ mpn, manufacturer, description, + specs, footprint, category_id, storage_id, @@ -38,7 +39,7 @@ INSERT_PART_QUERY = """ image, part_type ) - VALUES (?,?,?,?,?,?,?,?,?,?,?) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?) """ GET_PART_QUERY = """ SELECT p.*, c.name as cat, s.name as storage diff --git a/helpers.py b/helpers.py @@ -66,6 +66,7 @@ def print_part(p, history, get_files=False): print(f"Created: {p['insert_date']}" f"\tUpdated: {p['update_date']}\n") print(f"Description:\n{p['description']}\n") + print(f"Specs:\n{p['specs']}") if get_files: # extract the files from the blobs and store them on /tmp diff --git a/myChips.py b/myChips.py @@ -65,11 +65,15 @@ def add_part(mpn, quantity, category, storage, part_type): footprint = None datasheet = None image = None + specs = '' if 'specs' in p: for s in p['specs']: + specs += f"{s['attribute']['name']}: {s['display_value']}\n" if s['attribute']['shortname'] == 'case_package': footprint = s['display_value'] + if not specs: + specs = None if 'best_datasheet' in p: if p['best_datasheet']['mime_type'] == 'application/pdf': @@ -95,6 +99,7 @@ def add_part(mpn, quantity, category, storage, part_type): p['mpn'], p['manufacturer']['name'], p['short_description'], + specs, footprint, category, storage, diff --git a/schema.sql b/schema.sql @@ -17,6 +17,7 @@ CREATE TABLE IF NOT EXISTS parts ( mpn text, manufacturer text, description text, + specs text, footprint text, category_id integer NOT NULL, storage_id integer NOT NULL,