---
title: "Executing queries"
description: "Run SurrealQL with query(), call a SurrealQL function with run(), keep parameters on the connection with set() and unset(), and invoke DEFINE API endpoints with api() in the Rust SDK."
canonical_url: "https://surrealdb.com/docs/reference/rust/concepts/executing-queries"
sdk: "Rust SDK"
sdk_version: "4.0.1"
surrealdb_version: "4.x"
last_modified: "2026-11-24T05:29:47Z"
---

> Full SurrealDB documentation index: https://surrealdb.com/docs/llms.txt

# Executing queries

Run SurrealQL with query(), call a SurrealQL function with run(), keep parameters on the connection with set() and unset(), and invoke DEFINE API endpoints with api() in the Rust SDK.

The Rust SDK runs SurrealQL with `query()`, which takes one or more statements and binds variables to them, and calls a function defined in the database with `run()`. `set()` keeps a parameter on the connection for the queries that follow, and `unset()` removes it. `api()` invokes the endpoints defined with `DEFINE API`.

To read and write records without writing SurrealQL, see [data manipulation](/docs/reference/rust/concepts/data-manipulation.md). How results are read into Rust types is covered in [value types](/docs/reference/rust/concepts/value-types.md) and [flexible typing](/docs/reference/rust/concepts/flexible-typing.md), and [fetching linked records](/docs/reference/rust/concepts/fetch.md) shows how to follow record links in a query.

| Method | Description |
| --- | --- |
| [`db.query()`](/docs/reference/rust/methods/query.md) | Runs one or more SurrealQL statements against the database |
| [`db.run()`](/docs/reference/rust/methods/run.md) | Runs a SurrealQL function |
| [`db.set()`](/docs/reference/rust/methods/set.md) | Assigns a value as a parameter for this connection |
| [`db.unset()`](/docs/reference/rust/methods/unset.md) | Removes a parameter from this connection |
| [`db.api()`](/docs/reference/rust/methods/api.md) | Invokes the endpoints defined with `DEFINE API` on the selected namespace and database |
