partsdb

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

commit a0a9bda5a6649244659392817155fd836aeaa7bc
parent 604a8365c76e259cd68fb7ba76ec4cb86f0cfcfd
Author: Paco Esteban <paco@e1e0.net>
Date:   Mon, 15 Mar 2021 18:45:05 +0100

allow configuration for parts.db file location

Diffstat:
Mdatabase.py | 4++--
Mpartsdb.py | 3++-
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/database.py b/database.py @@ -82,9 +82,9 @@ DELETE_HISTORY_QUERY = "DELETE FROM parts_history WHERE part_id = ?" class PartsDB(): - def __init__(self): + def __init__(self, database): try: - self.conn = sqlite3.connect('parts.db') + self.conn = sqlite3.connect(database) self.conn.row_factory = sqlite3.Row except Error as e: print(e) diff --git a/partsdb.py b/partsdb.py @@ -12,7 +12,8 @@ from helpers import * from octopart import OctopartClient octo = OctopartClient(os.getenv('OCTOPART_TOKEN', None)) -db = PartsDB() +db = PartsDB(os.getenv('PARTSDB_FILE', + f"{os.getenv('HOME')}/.local/share/parts.db")) def add_part(mpn, quantity, category, storage, part_type):