Converting a CSV to a SQLite table to use for your custom GPT chatbot
You canThe best way to improve the accuracy of your chatbot's responses when dealing with data in CSV or Excel format is to import the data into a SQLite database that your chatbot can consume. This guide will show you the best way to do that.
Creating the SQLite database
Ensure you have sqlite
installed on your system. Then, in the termal, run the following command:
sqlite3 name_of_yourdb.db
Replace name_of_yourdb.db
with the name of the DB you would like to create.
Importing your data
In the SQLite instance that should now be open, run the following:
-
.mode csv
to enable CSV import mode -
.import /path_to_csv_file/csv_file.csv table_name
- Repeat step 2 for any additional tables you would like to import.
Keep in mind that each CSV will be a single table in your DB.
Verify the data
In the SQLite instance, you can use the following command to verify the table created:
.schema table_name
This will output the schema. You can check that the columns have been created correctly with the correct data types (for example ensure that column's that should be integer's are correct). This is an important step so make sure when ordering or ranking queries are used your bot can retrieve the correct information.
If there are wrong column types, you can either update them with a SQL command, or drop and recreate the table with the correct data types. You can then import the data in to the existing table with this command:
.import /path_to_csv_file/csv_file.csv table_name
Updating your chatbot
You are now ready to update your chatbot to use the SQLite database to answer visitor queries. To do this, you will need to go to Advanced -> Plugins in the sidebar of your chatbot.
From here select Install Plugin for the SQLite database plugin.
You can now select the database you created, specify any table names (this can be left blank to use all), and add any specific user or system prompts to improve the results of the bot. For example, you can specify that only specific columns should be used for ranking data.
Click Install Plugin to enable the plugin for your chatbot.
Your custom GPT bot will now use the data from your SQLite database to respond to your visitor questions.
Updating your SQLite database
If you need to update your SQLite database, you can load the database in a SQL editor like TablePlus and update or add any new data. Then just upload the new database for the chatbot to use the new data.
Not finding what you need? Reach out to our support team for help.
Contact Support