electronics4fun / smallPartDb

small python class for interfacing partDb
MIT License
3 stars 2 forks source link

Support for "Create parts from info provider" #1

Open Stefanhg opened 1 month ago

Stefanhg commented 1 month ago

Hello, I am working on making a script that can search the barcode on a part and check if it does not exist, and if not then create a new part based on "Create parts from info provider" functionality within part-db since it is really smart. I would like to use this library for searching but since the support for "Create parts from info provider" is not implemented I would like to ask if it can be implemented?

electronics4fun commented 1 month ago

Hi, not in the next days... but i take it in consideration

Stefanhg commented 1 month ago

I did also try and implement it myself but I came to the conclusion that the feature needs support in Part-DB but I'm not sure if you also come to the conclusion. It surely sucks having to sit down and enter every component you got in your storage system. Been spending many hours doing this already.

electronics4fun commented 1 month ago

I made it with DigiKey for testing. There is no dependency to PartDb. You get a lot of information from the DigiKey-API that you can use as you like. But of course, it make sense that this can be used for new (scanned) items. There is still the challenge, that if you search for a part (for example its name), that you get back a list with different ordernumbers, because the part is available as reel and as tape (or something else)... That must be catched in some way.

What i used (this is from an example):

import os
from pathlib import Path

import digikey
from digikey.v3.productinformation import KeywordSearchRequest
from digikey.v3.batchproductdetails import BatchProductDetailsRequest

import json

CACHE_DIR = os.path.abspath('./tmp')

if not os.path.exists(CACHE_DIR):
    os.makedirs(CACHE_DIR)

os.environ['DIGIKEY_CLIENT_ID'] = 'xxxx'
os.environ['DIGIKEY_CLIENT_SECRET'] = 'yyyy'
os.environ['DIGIKEY_CLIENT_SANDBOX'] = 'False'
os.environ['DIGIKEY_STORAGE_PATH'] = CACHE_DIR

dkpn = '296-6501-1-ND'
part = digikey.product_details(dkpn)

print("part:")
print(json.dumps(part))
Stefanhg commented 1 month ago

Agree. You can pull a lot of information from those. I just would like to reduce having to do if/else cases for each variable added which is why I wanted to automate it using the already implemented API. I use LCSC as my primary distributor and they don't have an API so that means I would have to re-implement what part-db already have implemented in their search engine. I have also found that there are duplicates when using Mouser since the components barcode does not include the xxx-(P/N) but typically duplicates does not share the full name so I can work around it.

electronics4fun commented 1 month ago

Not so sure if this is possible in an easy way (with PartDb). I will take a look. There are also coming some bugfixes here...

Stefanhg commented 1 month ago

Fantastic, thank you! We do like a few bugfixes :)