# How to Use SQLite

QSWAT+ and SWAT+ Editor use a [SQLite](https://www.sqlite.org/) database to hold model input data to allow easy manipulation by the user. The database is structured to closely resemble the SWAT+ input text files in order to keep a clean link between the model and editor.

## Opening the SQLite Database

We recommend using the SWAT+ Editor program provided to browse and edit SWAT+ input data. However, if you need to access the database, we recommend using:

* [SQLite Studio](https://sqlitestudio.pl/)

There are many other alternatives out there. A few of them are:

* [DB Browser for SQLite](http://sqlitebrowser.org/)
* [SQLite Manager, Firefox Add-On](https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager-webext/)

## Understanding Table Relationships

SWAT+ contains many cross-walks between files, and the database follows suit by creating foreign key relationships where applicable. In the SWAT+ text files, you will see files reference object names from another file. In the database however, these are done with an integer id. Relational databases make it easy to view the referenced row.

In SQLite Studio, right-click a foreign key id in a row of data, and select “Go to referenced row in table …” as shown in the image below. This will open the referenced row of data in a new tab.

![](https://48022380-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZjucbsiRtOOGctS4q0%2F-LZke7ChAm2EpH5jhNvh%2F-LZkeUbg8GmiyXPU8uUO%2Fforeign-key-link.png?alt=media\&token=846f03b4-8df2-4977-b3d6-ae7ed25cc82a)

Results in:

![](https://48022380-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZjucbsiRtOOGctS4q0%2F-LZke7ChAm2EpH5jhNvh%2F-LZkeZ7PlHMntUc2Wkjd%2Fforeign-key-results.png?alt=media\&token=b664261b-c3a5-499c-b7b7-1bb4cca503ff)


---

# Agent Instructions: 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://swatplus.gitbook.io/docs/1.2.3/user/how-to-use-sqlite.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.
