Skip to main content
Version: 1.x

Import command

The import command imports a SurrealQL script file into a local or remote SurrealDB database server.

BEFORE YOU START : Make sure you’ve installed SurrealDB — it should only take a second!

Command options

ArgumentsDescription

-e / --endpoint / --conn OPTIONAL

Sets the url of the database server to connect to

-u / --user REQUIRED

Sets master username for the database

-p / --pass REQUIRED

Sets master password for the database

--nsREQUIRED

Sets the desired namespace in which to import data

--dbREQUIRED

Sets the desired database into which to import data

Positional argument

ArgumentsDescription
fileREQUIRED

Sets the the path to the file which should be imported

Example usage

To perform a SurrealQL database import from a local file, in a terminal run the surreal import command with the required arguments.

surreal import --conn http://localhost:8000 --user root --pass root --ns test --db test downloads/surreal_deal_v1.surql

NOTE: The Import statement has a file size limit of 4 GiB per import, this prevents the import process from running out of memory and crashing. Please make sure your import file is under this limit.

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.

surreal import --help

The output of the above command :

Import a SurrealQL script into an existing database

USAGE:

surreal import [OPTIONS] <file>

ARGS:
<file> Path to the sql file to import


OPTIONS:
-e, --endpoint, --conn <conn> Remote database server URL to connect to
[default: https://cloud.surrealdb.com]

--db <db> The database to import the data into

-h, --help Print help information

--ns <ns> The namespace to import the data into

-p, --pass <pass> Database authentication password to use when connecting
[default: root]

-u, --user <user> Database authentication username to use when connecting [default: root]