Database

The Database Book lets you connect to a database and automate CRUD operations.

Prerequisites

Before you can work with databases in Kognitos, you must first learn the Database Book.

To configure the book, you need to have an active account for the database you intend to connect to, along with the following credentials for the database:

  • Username
  • Password
  • Host
  • Name
  • Engine

Database Book Operations

Working with Database Records

Interacting with database records is a core functionality when integrating databases with KOG. This section covers how to fetch data, create and modify database records, and delete them when necessary.

Fetching Data from Database

To fetch data from a database, you can specify conditions to retrieve specific records.

Retrieve a Record with Specific Attributes

get a person from the database whose
    first name is "John"
    last name is "Doe"

Retrieve a Record from a Specified Table with Conditions

the person's table is "employees"
get a person from the database whose
    department is "Engineering"
get the first person from the database whose
    department is "Sales"

Creating and Modifying Database Records

Adding New Records

To add a new record to a database, you need to specify the type of object you're creating and provide the necessary field values.

Example:

create a person in database with
    the first name is "John"
    the last name is "Doe"

Specify Table Name and Create a Record

the person's table is "personas"
create a person in database with
    the first name is "John"
    the last name is "Doe"
get a person from database whose ID is 3

Updating Existing Records

To update an existing database record, you must identify the record by its ID and specify the fields you want to update.

Example:

get a person from database whose ID is 3
set the person's name to "Jane Doe"

Change a Field of a Record

get a product from database whose ID is 15
change the product's price to "9.99"

Deleting Database Records

To delete a specific database record, you need to specify the record and its ID.

Example:

delete a person from the database with
    the ID is 123