Bouni / kicad-jlcpcb-tools

Plugin to generate BOM + CPL files for JLCPCB, assigning LCSC part numbers directly from the plugin, query the JLCPCB parts database, lookup datasheets and much more.
MIT License
1.19k stars 107 forks source link

Loading parts DB fails #550

Open dhoepfl opened 1 week ago

dhoepfl commented 1 week ago

Describe the bug Loading the parts DB fails with an exception “… library.py, line 368, … no such column: parts”.

I think the problem is introduced by commit ed495c0. The SQL statement is changed from

query = '''SELECT "LCSC Part" AS lcsc, "Stock" AS stock, "Library Type" AS type FROM parts WHERE parts MATCH ?'''
for number in lcsc:
    match_query = f'"LCSC Part:{number}"'
    cur.execute(query, (match_query,))

to

query = """SELECT "LCSC Part" AS lcsc, "Stock" AS stock, "Library Type" AS type FROM parts WHERE parts MATCH :number"""
cur.execute(query, {"number": number})

This drops the LCSC Part column name.

I think, this should be

query = """SELECT "LCSC Part" AS lcsc, "Stock" AS stock, "Library Type" AS type FROM parts WHERE "LCSC Part" MATCH :number"""

To Reproduce Steps to reproduce the behavior:

  1. Open JLCPCB-Tools

Expected behavior The main window should open.

KiCad Version

KiCad 8.0.5 JLCPBC tools 2024.10.01

travisjayday commented 2 days ago

Can confirm this problem exists. Ran into it on Kicad 8.0 plugin version 2024.10.01, made the change as described by OP, and the window would succesfully open again.

Bouni commented 1 day ago

Please check if the latest release fix the problem.

dhoepfl commented 16 hours ago

Problem is solved (mostly).

What I did:

Error log ``` --- Logging error --- Traceback (most recent call last): File "C:\Program Files\KiCad\8.0\bin\Lib\logging\__init__.py", line 1113, in emit stream.write(msg + self.terminator) ^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'write' Call stack: File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\plugin.py", line 28, in Run dialog = JLCPCBTools(None) File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\mainwindow.py", line 478, in __init__ self.init_library() File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\mainwindow.py", line 497, in init_library self.library = Library(self) File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\library.py", line 48, in __init__ self.setup() File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\library.py", line 54, in setup self.logger.info( Message: "Data directory 'jlcpcb' does not exist and will be created." Arguments: () 2024.11.05 11:24:14 - INFO - setup - Data directory 'jlcpcb' does not exist and will be created. 2024.11.05 11:24:14 - INFO - setup - Data directory 'jlcpcb' does not exist and will be created. 2024.11.05 11:24:14 - INFO - setup - Data directory 'jlcpcb' does not exist and will be created. --- Logging error --- Traceback (most recent call last): File "C:\Program Files\KiCad\8.0\bin\Lib\logging\__init__.py", line 1113, in emit stream.write(msg + self.terminator) ^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'write' Call stack: File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\plugin.py", line 28, in Run dialog = JLCPCBTools(None) File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\mainwindow.py", line 478, in __init__ self.init_library() File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\mainwindow.py", line 497, in init_library self.library = Library(self) File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\library.py", line 49, in __init__ self.check_library() File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\library.py", line 72, in check_library self.create_rotation_table() File "C:\Users\xxx\Documents\KiCad\8.0\3rdparty\plugins\com_github_bouni_kicad-jlcpcb-tools\library.py", line 235, in create_rotation_table self.logger.debug("Create SQLite table for rotations") Message: 'Create SQLite table for rotations' Arguments: () 2024.11.05 11:24:14 - DEBUG - create_rotation_table - Create SQLite table for rotations 2024.11.05 11:24:14 - DEBUG - create_rotation_table - Create SQLite table for rotations 2024.11.05 11:24:14 - DEBUG - create_rotation_table - Create SQLite table for rotations ```

So the plugin is usable now but there should be a refresh after downloading the parts DB (and the UI should be disabled while downloading the DB).