> For the complete documentation index, see [llms.txt](https://hrodebert.gitbook.io/qic-database-ver-1.0.0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hrodebert.gitbook.io/qic-database-ver-1.0.0/database/table_container.md).

# table\_container

### What is a table\_container

The `table_container` class is designed to manage table-like data structures and facilitate operations like selection, removal, filtering, and querying. It provides a flexible and type-safe interface for handling complex data queries.

### Obtaining the table\_container from a database

To perform a query you need to obtain the table\_container object from your database, you can do it by using the container\_execute method, this will return a shared pointer pointing to the table\_container

### **Methods**

#### **select(std::string number)**

Selects a specific record in the table or all records.

* **Parameters**:
  * `number`: Record index (string). Use `"*"` for all records.
* **Returns**: A pointer to the current instance.

#### **remove(std::string number)**

Marks specific records for removal based on the index.

* **Parameters**:
  * `number`: Record index (string). Use `"*"` to mark all records.
* **Returns**: A pointer to the current instance.

#### **from(std::string table\_to\_query)**

Specifies the table to query and loads its data.

* **Parameters**:
  * `table_to_query`: Name of the table to query.
* **Returns**: A pointer to the current instance.

#### **where(std::string value, std::any is, bool is\_not = false)**

Filters data rows based on a condition.

* **Parameters**:
  * `value`: Column name to filter on.
  * `is`: Value to compare against.
  * `is_not`: Whether to invert the condition (default: `false`).
* **Returns**: A pointer to the current instance.

#### **get\_output()**

Retrieves filtered results or deletes records (depending on the operation).

* **Returns**: A `table_vec` containing the filtered records.

### **Supported Data Types**

The class supports the following data types:

* **INT**
* **DOUBLE**
* **FLOAT**
* **STRING**
* **BOOL**

**Example**

```cpp
#include "qic.h"
#include <any>
#include <chrono> // For time measurement
#include <iostream>
#include <unordered_map>

int main() {
    data_base db;

    // Open the database
    db.open_database("mydatabase.db");

    // Set the number of compiling threads
    db.compiling_threads = 1;

    // Add a table to the database
    auto op = db.add_table(
        "COMPANY",
        std::unordered_map<std::string, data_type>{
            {"ID", INT},
            {"NAME", STRING},
            {"AGE", INT},
            {"ADDRESS", STRING},
            {"SALARY", DOUBLE}
        }
    );

    // If adding the table fails, load the existing table
    if (op.stat == FAILED) {
        db.load_table("COMPANY");
    }

    // Remove entries from the "COMPANY" table
    db.container_execute()->remove("*")->from("COMPANY")->get_output();

    // Query the "COMPANY" table
    auto result = db.container_execute()->select("*")->from("COMPANY")->get_output();

    // Display the query results
    for (const auto& query_result : result) {
        std::cout << "------------------------" << std::endl;
        std::cout << "ID : " << std::any_cast<int>(query_result.at("ID")) << std::endl;
        std::cout << "NAME : " << std::any_cast<std::string>(query_result.at("NAME")) << std::endl;
        std::cout << "AGE : " << std::any_cast<int>(query_result.at("AGE")) << std::endl;
        std::cout << "ADDRESS : " << std::any_cast<std::string>(query_result.at("ADDRESS")) << std::endl;
        std::cout << "SALARY : " << std::any_cast<double>(query_result.at("SALARY")) << std::endl;
        std::cout << "------------------------" << std::endl;
    }

    // Save the database
    db.save();

    // Pause execution until user input
    char pause;
    std::cin >> pause;

    // Close the database
    db.close();

    return 0;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hrodebert.gitbook.io/qic-database-ver-1.0.0/database/table_container.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
