SQLAI.ai

Import Your Data Source Schema

Table of contents

Introduction

Integrating your database schema augments the precision of the generated SQL queries and simplifies their construction, as the AI recognizes your database schema's tables and columns. This also enhances explanations and optimizations. Here are the various methods to incorporate your database schema, including manually, via CSV, or through any other format.

Go to the Add Data Source page and select your preferred method to import the database schema.

Import database schema
Import database schema

Here are the different import options:

CSV Import

Selecting "Import via CSV" provides you with a SQL query that automatically fetches the necessary table and column names. This method is prompt and straightforward. On the Import via CSV screen, you can:

  • Enter the database name
  • Select the database engine
  • Copy and paste the CSV that holds your database schema

To fetch the database schema in CSV format:

  • Execute the following SQL query on your database
  • Export the result as CSV
  • Copy and paste the results in the text area
Import database schema via CSV
Import database schema via CSV

Finally, click "Add" to complete the process.

Manual Import

It's possible to add your database schema manually using the subsequent format (table name: column name, column name, column name):

            
users: id, name, email, password, created_at, updated_at posts: id, title, body, created_at, updated_at comments: id, body, user_id, post_id, created_at, updated_at ...

Merely add the necessary tables and columns, input the database name and select the engine type.

Manually add database schema
Manually add database schema

Finally, click "Add" to complete the process.

Importing in Another Format

Your database schema can be imported in any desired format. These include JSON, HTML, plain text, or a custom format such as Prisma's schema.prisma (among other ORMs). The only prerequisite is that the database schema must be structured in a way that the AI can understand.

  • Note: While this method can be constructive for smaller database schemas, you might lose several features, such as the ability to omit tables and auto-suggest. CSV import is the recommended method.
Add database schema in any format
Add database schema in any format

Compared to Connecting to Data Source

Connecting to your data source will automatically import the database schema. Importing it with the above method is another way to use our service if connecting isn't desired or an option. Connecting to your data sources gives you additional powerful capabilities like running generated queries directly.