How To Use AI Bot With or Without Database Schema
Table of Contents
As soon as you have logged in you can start interacting with AI Bot and have it generate SQL queries for you (clicking the Settings button and choosing the database engine you use is recommended, i.e.
mssql). No further configuration is needed, however if you want to ensure that AI Bot generates highly accurate SQL queries (i.e. SQL queries that can be executed directly) and with minimal effort, you can add your database schema as context. This can be done in 2 ways:
- adding it manually or with CSV import
- connecting to your database
Below we will show how you can use AI Bot with your specific database. The settings for adding your database is found by clicking the settings button:
Privacy note: Sensitive database schema information is only stored locally in your browser.
See how to use AI Bot with or without database schema in the video below:
Without database schema
As noted in the introduction you can also use AI Bot to generate SQL queries for you even without it knowing your database schema. Using AI Bot in the mode, it will use best practices to generate SQL queries for you and try to guess the database schema that your input implies. Asking AI Bot to generate a SQL query for a input like
get 10 latest users with their comments will likely return a useful result, but you might need to specify a foreign key to ensure that is is accurate like
get 10 latest users with their comments via comments.user_x_id. This pattern of adding various database schema constraints inline is useful when the database schema isn't available to AI Bot.
You can read more about using AI Bot without adding your database schema here.
Manually adding database schema
Manually adding your database schema either by typing or by running a SQL query that extracts the database schema as CSV is great for use cases where you can't connect to your database. To add your database schema click the Settings button and click Add or edit database. This takes you to the Add tables and columns page where you will see different input fields and instructions for adding your database schema:
Beyond adding your database schema, you can also manage database schemas that you have already imported. Once you have added the database schema, you can navigate back to the SQL builder and now your database schema will automatically be added to AI Bot.
Connecting to your database
To connect to your database you need a connection URL in the following format:
You can read more on how to connect to your database here. Once you have entered the database connection URL and successfully connected to your database, AI Bot has access to the database schema (stored locally in the browser).
Beyond allowing AI Bot to generate highly accurate SQL queries, connecting to your database also enables you to run the generated SQL queries directly on your database and get the data insights you need:
This makes getting up to date information for your business or application easy, not only for technical users with SQL knowledge but for any user. If you need some inspiration for what to ask AI Bot, you can click the What can I ask? button in the SQL builder to get some examples.