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

Stock and Type are no longer updated #510

Closed
Bouni opened this issue Aug 2, 2024 · 0 comments · Fixed by #511
Closed

Stock and Type are no longer updated #510

Bouni opened this issue Aug 2, 2024 · 0 comments · Fixed by #511
Assignees
Labels
bug Something isn't working

Comments

@Bouni
Copy link
Owner

Bouni commented Aug 2, 2024

This issue was introduced by #503

get_part_details no longer yield any results

def get_part_details(self, lcsc):
"""Get the part details for a list of LCSC numbers using optimized FTS5 querying."""
with contextlib.closing(sqlite3.connect(self.partsdb_file)) as con:
con.row_factory = sqlite3.Row # To access columns by names
cur = con.cursor()
results = []
query = '''SELECT "LCSC Part", "Stock", "Library Type" FROM parts WHERE parts MATCH ?'''
# Use parameter binding to prevent SQL injection and handle the query more efficiently
for number in lcsc:
# Each number needs to be wrapped in double quotes for exact match in FTS5
match_query = f'"LCSC Part:{number}"'
cur.execute(query, (match_query,))
results.extend(cur.fetchall())
return results

@Bouni Bouni added the bug Something isn't working label Aug 2, 2024
@Bouni Bouni self-assigned this Aug 2, 2024
@Bouni Bouni linked a pull request Aug 2, 2024 that will close this issue
@Bouni Bouni closed this as completed in #511 Aug 5, 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

Successfully merging a pull request may close this issue.

1 participant