mirror of
https://github.com/Sosokker/Packaged-Food-Explorer.git
synced 2025-12-19 05:04:06 +01:00
13 lines
407 B
Python
13 lines
407 B
Python
import sqlite3
|
|
|
|
class FoodSearch:
|
|
def __init__(self, db_path):
|
|
self.conn = sqlite3.connect(db_path)
|
|
self.cursor = self.conn.cursor()
|
|
|
|
def search(self, user_input) -> list:
|
|
query = f"SELECT * FROM food_data WHERE product_name LIKE '%{user_input}%'"
|
|
self.cursor.execute(query)
|
|
results = self.cursor.fetchall()
|
|
|
|
return results |