-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse cube-finder-db.db and include MPNs in output #6
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! Extracting MPNs is something I already thought of when writing this extractor. Great to see that it can now be used!
res = self._cur.execute( | ||
"SELECT strValue, numValue FROM cpn_has_attribute " | ||
"LEFT JOIN attribute " | ||
"ON attribute.id = cpn_has_attribute.attribute_id " | ||
"WHERE cpn_id = :cpn_id " | ||
"AND attribute.name = :attribute_name", | ||
dict( | ||
cpn_id=cpn_id, | ||
attribute_name=attribute_name, | ||
), | ||
).fetchone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a multi-line string for easier readability:
res = self._cur.execute("""
SELECT strValue, numValue FROM cpn_has_attribute
LEFT JOIN attribute
ON attribute.id = cpn_has_attribute.attribute_id
WHERE cpn_id = :cpn_id
AND attribute.name = :attribute_name
""",
dict(
cpn_id=cpn_id,
attribute_name=attribute_name,
),
).fetchone()
"temperature_min": -40.0, | ||
"temperature_max": 125.0, | ||
"packing_type": "Tape and Reel", | ||
"status": "Coming soon" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably ignore or re-map "Coming soon" parts. But that's a choice for the parts generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was exactly my intention! 😃 In addition, for the non-skipped MPNs I'd also add this status information as an attribute to the parts because the status "NRND" is then directly visible in the component picker dialog.
But as you said, this is the decision of the parts generator.
I saw that in the STM32 database directory there's also an SQLite database including the exact MPNs for all MCUs. Since the MPNs are now useful for LibrePCB (to export accurate BOMs), I extended the script to also extract that data from this database and include it in the generated JSON files.
Example output (new node
parts
):Note that the temperature min/max are now redundant in the output files, but it makes sense to have them in the
parts
section because they may be different for the different MPNs. We might consider removing them from the outer node now...In addition, there are actually many more attributes stored in the database but for now I extracted only 5 of them which are most useful for LibrePCB. One might argue that we should include all existing data into the JSON files(?)
Regarding license, probably it doesn't make a difference whether we fetch data from an XML file or from an SQLite database so I suspect this change does not affect the license situation of our generated parts.
TODO:
librepcb-parts-generator
since this repository is just responsible for putting data from ST into a useful format.../cc @dbrgn