vanna-ai / vanna

🤖 Chat with your SQL database 📊. Accurate Text-to-SQL Generation via LLMs using RAG 🔄.
https://vanna.ai/docs/
MIT License
9.12k stars 673 forks source link

Database connection issue while using SQLite3 #531

Open HaaaSiiiib opened 3 days ago

HaaaSiiiib commented 3 days ago

It is not getting the connection with my local sqlite database. And as a result it can't get the tables when I am making a prompt. I am using the official documentation. Here is the code :

class MyVanna(ChromaDB_VectorStore, OpenAI_Chat):
    def __init__(self, config=None):
        ChromaDB_VectorStore.__init__(self, config=config)
        OpenAI_Chat.__init__(self, config=config)
vn = MyVanna(config={'api_key': api_key, 'model': vanna_model_name,'allow_llm_to_see_data': True})
vn.connect_to_sqlite('backend/db.sqlite3')
df_ddl = vn.run_sql("SELECT type, sql FROM sqlite_master WHERE sql is not null")
for ddl in df_ddl['sql'].to_list():
  vn.train(ddl=ddl)
vn.train(ddl="""
    *** SQL for creating my table ***
    )
""")
vn.train(sql=query)
training_data = vn.get_training_data()
from vanna.flask import VannaFlaskApp
app = VannaFlaskApp(vn, allow_llm_to_see_data=True)
app.run()

It should be connected to the database at least.