Importing Data
This topic covers how to quickly import data from an existing Postgres database or CSV file into ParadeDB.
From Postgres
Prerequisite Ensure that you have psql
installed on your machine. This
will provide the necessary pg_dump
and pg_restore
command line utilities.
- From your terminal, run
pg_dump
to create a copy of your existing database.
pg_dump -Fc --no-acl --no-owner \
-h <host> \
-U <username> \
<dbname> > old_db.dump
Note that host
, username
, and dbname
are the host address, username, and database name of your existing
database, respectively.
You can also create copies of certain tables:
pg_dump -Fc --no-acl --no-owner \
-h <host> \
-U <username> \
-t <table_name_1> -t <table_name_2>
<dbname> > old_db.dump
- Run
pg_restore
to copy your data into ParadeDB:
pg_restore --verbose --clean --no-acl --no-owner \
-h <host> \
-U <username> \
-d <dbname> \
old_db.dump
Note that host
, username
, and dbname
are now the credentials of your ParadeDB database.
From CSV File
- Prepare a
actors.csv
file on your machine at/path/to/actors.csv
with the following data.
First Name,Last Name
1,Will,Smith
2,Denzel,Washington
- Use
psql
to connect to ParadeDB.
psql -h <hostname> -U <user> -d <dbname> -p <port> -W
- Inside the
psql
shell, create a table that matches theactors.csv
schema.
CREATE TABLE actors (
id SERIAL,
first_name TEXT,
last_name TEXT,
);
- Load the data using the
\copy
option.
\copy actors FROM '/path/to/actors.csv' DELIMITER ',' CSV HEADER;
- Ensure that the CSV file was uploaded successfully.
SELECT * FROM actors;
From Object Store
Please refer to the ParadeDB Analytics documentation for instructions on how to load data from an external object store or table format into ParadeDB.
For Further Assistance
The paradedb.help
function opens a Github Discussion that the ParadeDB team will respond to.
SELECT paradedb.help(
subject => $$Something isn't working$$,
body => $$Issue description$$
);
Was this page helpful?