SurrealDB Docs Logo

Enter a search query

use_ns(), use_db()

Switch to a specific namespace and database.

Method Syntax
db.use_ns(ns).use_db(db)

Arguments

ArgumentTypeDescription
ns

Switches to a specific namespace.

db

Switches to a specific database.

Example usage

use surrealdb::engine::remote::ws::Ws; use surrealdb::Surreal; #[tokio::main] async fn main() -> surrealdb::Result<()> { let db = Surreal::new::<Ws>("127.0.0.1:8000").await?; db.use_ns("ns").use_db("db").await?; Ok(()) }

See also

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install