I’d like to share the following two PHP scripts to read KiCad netlists into my web application (postgresql-) database, may be they are useful for someone. The scripts use PDO so they should work with other databases as well.
For this purpose, I always keep a field “RLID” in the schematic which is used by the script.
“uploadKicadNetlist.php” is just for selecting the file (the XML file that is created when you hit the BOM button in KiCad) and is called from another form by a request with arguments “artID” and “artName” where the latter is just for information. artID is the article number in my database where the BOM has to be added.
It allows two methods: keep the old BOM if one already exists and only merge it with the new one (so screws, housings or whatever is not in the schematic remains there) or delete any existing BOM before reading the new one.
The second script, “readKicadNetlist.php” does the real job. Of course, you would have to adapt the field and table names to match your system.
There is a “required” file “connect.php” which just opens the connection and creates the $pdo object.
uploadKicadNetlist.php (3.3 KB) readKicadNetlist.php (3.4 KB)
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.