Restores the database from a file.
WebSocket connections currently do not support exports and imports. Be sure to use an HTTP endpoint and the protocol-http feature when using this method.
Method Syntax
db.import(source)
Example usage
The following example assumes the presence of a file called backup.surql in the same directory as the current project. To quickly create it, copy and paste the example for the .export() method.
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".to_string(),
password: "secret".to_string(),
})
.await?;
db.use_ns("main").use_db("main").await?;
db.import("backup.surql").await?;
Ok(())
}
See also
Restores the database from a file.
WebSocket connections currently do not 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: "secret",
})
.await?;
db.use_ns("main").use_db("main").await?;
db.import("backup.surql").await?;
Ok(())
}
See also