SQLite
Anyquery is based on SQLite. Therefore, you can easily attach a SQLite database to Anyquery.
Connection string
The connection string for SQLite has the following format:
Connection options
file
: The path to the SQLite database file.mode
: The mode to open the database file. The default isrw
(read-write). You can also usero
(read-only) ormemory
(in-memory).immutable
: If set totrue
, the database file is opened in immutable mode. This means that the database file is read-only and cannot be modified.
Attach a SQLite database
You have two options to attach a SQLite database to Anyquery:
- Attach it on startup by registering a connection in the configuration database.
- Run the
ATTACH DATABASE
command in the shell (or MySQL client).
Attach on startup
To attach a SQLite database on startup, you need to register a connection in the configuration database. You can do this by running the following command:
Then, provide the connection string, SQLite as the database type and a name for the connection. The name is used to reference the connection in the queries. For example, if you provide the name mydb
, you can reference the connection in a query like this:
The CEL filter will be ignored when querying the attached SQLite database.
Attach in the shell
To attach a SQLite database in the shell, you can run the ATTACH DATABASE
command. For example, to attach a database located at /path/to/database.db
, you can run the following command:
Then, you can reference the attached database in a query like this: