Skip to content
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

Loading parts DB fails #550

Open
dhoepfl opened this issue Oct 23, 2024 · 4 comments
Open

Loading parts DB fails #550

dhoepfl opened this issue Oct 23, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@dhoepfl
Copy link

dhoepfl commented Oct 23, 2024

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
Copy link

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
Copy link
Owner

Bouni commented Nov 4, 2024

Please check if the latest release fix the problem.

@dhoepfl
Copy link
Author

dhoepfl commented Nov 5, 2024

Problem is solved (mostly).

What I did:

  • Uninstalled plugin
  • Applied pending uninstall
  • Checked: No longer there
  • Installed version 2024-11-01
  • Applied pending
  • Open PCB
  • Open plugin (unrelated error, might be a bug in KiCad)
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
  • List is empty
  • Parts DB is downloaded
  • List is (still) empty
  • Close plugin
  • Reopen plugin
  • List is populated

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).

@Bouni
Copy link
Owner

Bouni commented Nov 7, 2024

I noticed that the list is not populated after a DB download but I had no time to look into it so far ...

Good that it works for you otherwise

@Bouni Bouni added the bug Something isn't working label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants