Parse cube-finder-db.db and include MPNs in output#6
Draft
ubruhin wants to merge 4 commits into
Draft
Conversation
dbrgn
approved these changes
Sep 1, 2023
Member
dbrgn
left a comment
There was a problem hiding this comment.
Very cool! Extracting MPNs is something I already thought of when writing this extractor. Great to see that it can now be used!
Comment on lines
+67
to
+77
| 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() |
Member
There was a problem hiding this comment.
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" |
Member
There was a problem hiding this comment.
We should probably ignore or re-map "Coming soon" parts. But that's a choice for the parts generator.
Member
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):{ "names": { "name": "STM32C011D6Yx", "ref": "STM32C011D6Yx", "family": "STM32C0", "line": "STM32C0x1", "rpn": "STM32C011D6" }, "package": "WLCSP12", "silicon": { "core": "ARM Cortex-M0+", "die": "DIE443" }, "info": { "flash": 32, "ram": 6, "io": 10, "frequency": 48, "voltage": { "min": 2.0, "max": 3.6 }, "temperature": { "min": -40.0, "max": 85.0 } }, "parts": [ { "mpn": "STM32C011D6Y6TR", "temperature_min": -40.0, "temperature_max": 85.0, "packing_type": "Tape and Reel", "status": "Active" }, { "mpn": "STM32C011D6Y3TR", "temperature_min": -40.0, "temperature_max": 125.0, "packing_type": "Tape and Reel", "status": "Coming soon" } ], "gpio_version": "STM32C0xx_gpio_v1_0", /* ... */ }Note that the temperature min/max are now redundant in the output files, but it makes sense to have them in the
partssection 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-generatorsince this repository is just responsible for putting data from ST into a useful format.../cc @dbrgn