Nov 25, 2024
Get Started
In GuruSup, you can integrate external data sources to enrich the responses of your model. There are two main types of data sources you can use: SQL databases and APIs. Below is an explanation of how to create and configure these data sources in your GuruSup account.
Creating Data Sources
In GuruSup, you can integrate external data sources to enrich the responses of your model. There are two main types of data sources you can use: SQL databases and APIs. Below is an explanation of how to create and configure these data sources in your GuruSup account.1. Create a Data SourceTo begin, you need to create a data source. To do this:Go to the Data Source menu.Choose a descriptive name for your data source.Select the type of source: Database (SQL) or API.
Connect a Database (SQL)
If you choose to use an SQL database, you will be asked to provide the following information:
Database System: Select the type of database (e.g., MySQL).
Host: The connection address to the database server.
Port: The access port to the server.
Database Name: The name of the database you want to connect to.
Username and Password: The credentials to access the database.
Once this information is entered, click save, and the connection will be established.
Connect an API (Endpoint)
If you prefer to use an API, follow these steps:
Define a name for the API.
Enter the Host of the API (the base URL).
Choose the authentication type. Typically, basic authentication is used.
Add the required headers to authenticate the request.
Once these steps are completed, the API will be properly configured.
Add Data to the Source
Once the data source is set up, you need to add the specific data you want to use in your templates. Depending on the type of source, you can do the following:
For an API: Add an endpoint (e.g.,
/users
) and choose the request type (GET, POST, etc.). Set up the headers or the body of the request.For an SQL database: Enter a direct SQL query that will be executed on the database. You can use parameters that will automatically be replaced within the query.
5. Parameters in SQL Queries
If your data source uses SQL, you can incorporate parameters within the queries. Parameters are defined within curly braces {}
and can be dynamically replaced in the query body. This allows for more flexible and reusable queries in different contexts.
Link the Data Source to a Template
Once you have created and configured your data sources, you can link them to your templates so the model can use that information when generating responses. To do this:
Go to Templates in the menu.
Select the template you want to associate with the data source.
Add the corresponding data source.