llmware-ai / llmware

Unified framework for building enterprise RAG pipelines with small, specialized models
https://llmware-ai.github.io/llmware/
Apache License 2.0
4.26k stars 807 forks source link

unable to open sqlite database #906

Open anandanatarajan opened 2 weeks ago

anandanatarajan commented 2 weeks ago

Hi, my system is windows 11 with 32GB RAM , using python 3.12 , i am trying to fiddle with llmware nlp to sql using a csv file, after installing the llmware i copy pasted "examples/Structured_Tables/loading_csv_into_custom_table-2a.py" this code, the python environment is already installed with sqlite. but when i run i encounter this error

File "C:\python312\Lib\site-packages\llmware\resources.py", line 3917, in insert_rows if self.build_table(): ^^^^^^^^^^^^^^^^^^ File "C:\python312\Lib\site-packages\llmware\resources.py", line 3273, in build_table conn = self.get_connection(table_name=self.table_name, type="write") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python312\Lib\site-packages\llmware\resources.py", line 3356, in get_connection self.db_connection = CollectionWriter(self.table_name, account_name=self.account_name, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python312\Lib\site-packages\llmware\resources.py", line 228, in init self._writer = SQLiteWriter(self.library_name, account_name=self.account_name, custom_table=custom_table, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python312\Lib\site-packages\llmware\resources.py", line 2564, in init self.conn = _SQLiteConnect().connect(library_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python312\Lib\site-packages\llmware\resources.py", line 3083, in connect self.conn = sqlite3.connect(db_file) ^^^^^^^^^^^^^^^^^^^^^^^^ sqlite3.OperationalError: unable to open database file

the folder is having full rights and i am able to create and manipulate sqlite db from a simple python program with out any issues. struck with this for past 2 days any help ?

doberst commented 2 weeks ago

@anandanatarajan - thanks for raising this - we saw a similar issue to this recently with SQLite ... we will dig into it - will revert as soon as we have an update.

doberst commented 2 weeks ago

@anandanatarajan - what IDE are you using? Could you please check a couple of things: --try fast start example #1 - which also writes to SQLite - to check if you get the same error --on command line, or IDE terminal, please check: os.environ.get("USERPROFILE") path --location of llmware_data path, e.g., by default, it will be something like: "C:\Users\yourname\llmware_data" and in the subpath "\llmware_data\accounts\" you should see the sqlite_llmware.db file - which is the sqlite db --it is possible that the sqlite db is corrupted - assuming you just created it, you could delete it and start fresh --i suspect it is a path issue related to the environment/IDE, as I am running the example on Windows without any issues...

anandanatarajan commented 2 weeks ago

@doberst , i am using vs code , and used "pip install llmware" to install. the python is present in c:\python312 and the llmware is also present inside it only "C:\python312\Lib\site-packages\llmware\" there is no llmware folder in userprofile location and there is no llmware_data folder to. I will try to create manually the llmware_data folder in userprofile and update

anandanatarajan commented 2 weeks ago

@doberst managed to resolve the issue by creating relevant folders in the mentioned location. not sure why it was not created in pip install.

doberst commented 2 weeks ago

@anandanatarajan - thanks for closing the loop -and for catching this ... In most of the major classes, we initiate a setup function implicitly if certain file paths are not set up (e.g.., first time use) - but this was missing in the CustomTable class - so for first-time use, it generates the error you were seeing. We will be adding the 'implicit setup' into CustomTable later today. Appreciate your help on this. 👍

doberst commented 2 weeks ago

@anandanatarajan - thanks again, we have merged the defensive check into the CustomTable class, so it will create the llmware workspace on first time use. Just to avoid any issues as you do more with llmware, my recommendation is to delete the 'manual' file path that you created- and then run:

import llmware.configs import LLMWareConfig
LLMWareConfig.setup_llmware_workspace()

or git clone from the repo and then run the example again (and it will take care of setting up all of the supporting folder paths the right way.). Hope that makes sense. Thanks again for checking out llmware and for sharing this issue! 👍