> For the complete documentation index, see [llms.txt](https://nongnue.gitbook.io/sectum-ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nongnue.gitbook.io/sectum-ai/sectum-ai-cover/database-usage.md).

# Database Usage

**Requirements**

Currently, only SQLite is supported. [SQLite](https://www.sqlite.org/) operates using a local `.db` file for data storage and retrieval, as opposed to a server-based database.

To view the tables, you'll need SQLite installed. However, to begin, you can simply create an empty `.db` file using the `touch` command. For example:

Copy

Copy

```
touch run_tests.db
```

**Running with an external DB**

You can run Cover Agent using the `--log-db-path` option. For example:

Copy

Copy

```
cover-agent \
  --source-file-path "templated_tests/python_fastapi/app.py" \
  --test-file-path "templated_tests/python_fastapi/test_app.py" \
  --code-coverage-report-path "templated_tests/python_fastapi/coverage.xml" \
  --test-command "pytest --cov=. --cov-report=xml --cov-report=term" \
  --test-command-dir "templated_tests/python_fastapi" \
  --coverage-type "cobertura" \
  --desired-coverage 70 \
  --max-iterations 10 \
  --log-db-path "run_tests.db"
```

Cover Agent will create a table called `unit_test_generation_attempts` within the database.

**Integration Tests**

Run the integration test suite and provide the local `.db` file to each Docker container.

Copy

Copy

```
LOG_DB_PATH="<full_path_to_root_folder>/run_tests.db" tests_integration/test_all.sh
```

**Observing the test data**

View the test results using either an external database viewer or the basic SQLite command-line tool.

Copy

Copy

```
sqlite3 run_tests.db
```

After executing some tests, a table named `unit_test_generation_attempts` will be created.

Copy

Copy

```
sqlite> .tables
unit_test_generation_attempts
```

To get the definition of the table run:

Copy

Copy

```
sqlite> PRAGMA table_info(unit_test_generation_attempts);
0|id|INTEGER|1||1
1|run_time|DATETIME|0||0
2|status|VARCHAR|0||0
3|reason|TEXT|0||0
4|exit_code|INTEGER|0||0
5|stderr|TEXT|0||0
6|stdout|TEXT|0||0
7|test_code|TEXT|0||0
8|imports|TEXT|0||0
```

To display all test results run the query:

Copy

Copy

```
select * from unit_test_generation_attempts;
```

This query may be easier to view outside of the CLI.

You can also filter the results to show only failed tests, for example:

Copy

Copy

```
sqlite> select * from unit_test_generation_attempts where status = "FAIL";
```


---

# 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 following URL with the `ask` and `goal` query parameters:

```
GET https://nongnue.gitbook.io/sectum-ai/sectum-ai-cover/database-usage.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

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.
