BEFORE YOU START
Command options
| Arguments | Description |
|---|---|
-e / --endpoint
| Sets the url of the database server to connect to. Defaults to http://127.0.0.1:8000 if not specified |
-u / --user
| Sets master username for the database |
-p / --pass
| Sets master password for the database |
-t / --token
| Sets the authentication token to use when connecting to the server. Connect to SurrealDB using a JWT instead of user credentials |
--ns
| Sets the desired namespace in which to import data |
--db
| Sets the desired database into which to import data |
Positional argument
| Arguments | Description |
|---|---|
file
| Sets the path to the file to import |
Example usage
To perform a SurrealQL database import from a local file, in a terminal run the surreal import command with the required arguments.
Using token-based authentication:
Note
Using environment variables
When using the surreal import command, you can also use environment variables to set the values for the command-line flags.
Important
For more on the environment variables available for CLI commands or SurrealDB instances in general, see the environment variables page.
OPTION IMPORT
The output of a database export includes a line that contains the keywords OPTION IMPORT. This command is used internally to ensure that side effects do not run when the data is imported, such as events and table views.
As of SurrealDB 3.0.4, this line must be present in order to use the /import endpoint. If side effects when importing a .surql file are desired, remove the OPTION IMPORT line and use the /sql endpoint instead.
Importing data from other databases and sources
To import data from other sources besides .surql files (such as PostgreSQL, MongoDB, CSV data, Kafka, etc.), see the migrations section of the documentation.
Command help
To see the help information and usage instructions, in a terminal run the surreal import --help command without any further arguments. This command gives general information on the arguments, inputs, and additional options for the import command.
The output of the above command: