SchrodingersGat / KiBoM

Configurable BoM generation tool for KiCad EDA (http://kicad.org/)
MIT License
352 stars 95 forks source link

Add (optional) database support for adding or modifying fields #77

Closed cnieves1 closed 3 years ago

cnieves1 commented 4 years ago

Support is optional, if mysql.connector module is installed. It is automatically detected.

With this PR, field values can be retrieved from a database, or new fields can be created using database queries. One query is performed for each component, and there is support for including a component attribute or field's value in the query.

Queries and database stored procedures are supported. The return value can be assigned to a given field's name. If field's name is "none", return value is ignored.

Queries or calls to stored procedures are defined in bom configuration file, so they can be defined/customized by users.

set-soft commented 3 years ago

I'm curious: Why do you need a database and you can't use the component fields?

I mean: Why don't you use a tool to take the data from the database and fill the corresponding fields in the components inside the schematic?

I use Digi-Key's database to fill data like "Manufacturer name", "Manufacturer Code", "Temp. range", etc. But the data is finally stored in the schematic. So you can send it to another person without needing extra files.

I guess you have reasons, that's why I'm asking.

SchrodingersGat commented 3 years ago

Hi @cnieves1 thanks for the contribution (and sorry for the large delay in response). I feel that this is creeping too far beyond the scope of this project. I think that this would be better served as an external tool which operates on the BOM file generated by KiBoM...

cnieves1 commented 3 years ago

Hi @set-soft, We have a small database with internal part numbers. This patch allowed to generate a BOM including internal part numbers directly without modifying the schematic.

set-soft commented 3 years ago

@cnieves1 I suggest using scripts for that. When the eeschema python bindings are finished it will be much simpler, but parsing the .sch files isn't hard. Another option is to just apply the changes to the XML netlist before calling KiBoM. XML is supposed to be transformable. I never used XSLT but perhaps it could help.