I am currently developing a chatbot to interact with an already existing database that is coded in MySql. As for the framework, I am using django and trying to implement async functionalities. I am stuck in a part of the code that handles the RAG request. The specific part is down below: Reference code.
Open the image in a new tab, in order to be able to zoom. The code is pretty extensive.
The problem is that when finishing the sql_database function and returning it to the load_process_database function, I get the error of:
Just so you know, this error was customised by me. That is why is says that the is an error during the vectorstore initialization.
The full file code is attached.
full_code.txt (Size: 19.76 KB / Downloads: 1)
Thank you in advance
Open the image in a new tab, in order to be able to zoom. The code is pretty extensive.
The problem is that when finishing the sql_database function and returning it to the load_process_database function, I get the error of:
Error:Unexpected error during vectorstore initialization: DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 23796 and this is thread id 28192.
Error type: <class 'django.db.utils.DatabaseError'>
Error args: ("DatabaseWrapper objects created in a thread can only be used in that same thread. The object with alias 'default' was created in thread id 23796 and this is thread id 28192.",)
Just so you know, this error was customised by me. That is why is says that the is an error during the vectorstore initialization.
The full file code is attached.

Thank you in advance
Larz60+ write Mar-04-2025, 06:12 AM:
Rather than using attachments or external links, please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Rather than using attachments or external links, please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.