SurrealDB Docs Logo

Enter a search query

import()

Restores the database from a file.

Note

WebSocket connections currently do not currently support exports and imports. Be sure to use an HTTP endpoint when using this method.

Method Syntax
db.import(source)

Example usage

use surrealdb::engine::any::connect; use surrealdb::opt::auth::Root; #[tokio::main] async fn main() -> surrealdb::Result<()> { let db = connect("http://localhost:8000").await?; db.signin(Root { username: "root", password: "root", }) .await?; db.use_ns("ns").use_db("db").await?; db.import("backup.surql").await?; Ok(()) }

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install