Database Operations

Overview

This manual is divided into several sections, each focusing on a specific aspect of using Kognitos with databases.

Introduction

The integration offers a powerful and intuitive way to interact with database data and functionalities. This integration enables users to perform a wide range of operations on database records, including connecting to databases, querying, creating, updating, and deleting records. This section provides an overview of the integration.

Prerequisites for working with Databases in Kognitos

Before you can start working with databases in Kognitos there are several prerequisites that need to be met:

  1. Database Account: You need to have an active account for the database you intend to connect to. Ensure you have the necessary permissions to perform CRUD (Create, Read, Update, Delete) operations.
  2. Database Engine: Kognitos supports various database engines such as MSSQL and PostgreSQL. Ensure your database engine is supported.
  3. Connection Details: Gather the necessary connection details including the database server URL, username, password, and database name.
  4. Basic Understanding of Database Tables and Records: Having a basic understanding of database tables and records will help you automate more effectively

Once these prerequisites are met, you are ready to start leveraging the power of Kognitos to enhance your database experience, making it more accessible, efficient, and customizable.


Setting Up Database Connection

Connecting to a Database

To interact with a database in Kognitos, establishing a secure connection to your database instance is the first critical step. This section outlines the credentials required for this connection and provides a detailed, step-by-step guide to connect successfully.

Required Credentials

To connect to a database, you will need the following credentials:

  1. Database Engine: The type of database engine you are using (e.g., MSSQL, PostgreSQL).
  2. Username: The username associated with your database account.
  3. Password: The password for your database account.
  4. Server URL: The URL of your database server.
  5. Database Name: The name of the database you want to connect to.

Step-by-Step Connection Process

  1. Gather Credentials: Ensure you have all the required credentials: database engine, username, password, server URL, and database name.

  2. Connect to Database: To initiate a connection to the database, use the following:

    connect to database with
        the engine is "<database_engine>"
        the username is "<username>"
        the server is "<server_url>"
        the database is "<database_name>"
    

    Replace <database_engine>, <username>, <server_url>, and <database_name> with your actual database engine, username, server URL, and database name, respectively.

    connect to database with
        the engine is "mssql"
        the username is "john.doe"
        the server is "example.database.windows.net"
        the database is "example_db"
    
  3. Verify Connection: After executing the above command, Kognitos will attempt to establish a connection to the database using the provided credentials. If the connection is successful, you can proceed with further operations like fetching, creating, or modifying database records. If the connection fails, verify your credentials and ensure that your database engine, username, password, server URL, and database name are correct.

  4. Connection Established: Once the connection is successfully established, you are ready to perform various operations on the database. You can now fetch data, create new records, update existing ones, delete records, and more.


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

connect to a database with
    the engine is "mssql"
    the username is "<username>"
    the server is "<host>.database.windows.net"
    the database is "<database>"
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:

connect to database with
    the engine is "mssql"
    the username is "<username>"
    the server is "<host>.database.windows.net"
    the database is "<database>"
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:

connect to a database with
    the engine is "mssql"
    the username is "<username>"
    the server is "<host>.database.windows.net"
    the database is "<database>"
get a person from database whose ID is 3
set the person's name to "Jane Doe"

Change a Field of a Record

connect to a database with
    the engine is "postgresql"
    the username is "<username>"
    the server is "<host>.database.com"
    the database is "<database>"
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:

connect to a database with
    the engine is "mssql"
    the username is "<username>"
    the server is "<host>.database.windows.net"
    the database is "<database>"
delete a person from the database with
    the ID is 123

By following these guidelines, you can effectively manage database records in Kognitos, from fetching and creating records to updating and deleting them as needed.


Glossary of Terms

  • CRUD (Create, Read, Update, Delete): The four basic operations of persistent storage in databases.
  • Database Engine: The underlying software that a database management system (DBMS) uses to create, read, update, and delete data from a database.
  • Database Record: A single data entry within a database table. For example, a person record in the Person table.
  • Database Table: A collection of related data entries in a database, organized in rows and columns. Each row represents a record, and each column represents a field in the record.

This documentation provides a comprehensive guide to using Kognitos for database operations, ensuring you can connect to databases, and manage records efficiently and effectively.