Import data into your service
To import data from a CSV file:
- Set up your service connection string
This variable holds the connection information for the target Tiger Cloud service.
In the terminal on the source machine, set the following:
See where to [find your connection details][connection-info].
- Create a [hypertable][hypertable-docs] to hold your data
Create a hypertable with a schema that is compatible with the data in your parquet file. For example, if your parquet file contains the columns ts, location, and temperature with typesTIMESTAMP, STRING, and DOUBLE:
- TimescaleDB v2.20 and above:
sql psql target -c "CREATE TABLE (
ts TIMESTAMPTZ NOT NULL,
location TEXT NOT NULL,
temperature DOUBLE PRECISION NULL
);" sql psql target -c "SELECT create_hypertable('', by_range('<COLUMN_NAME>'))" bash timescaledb-parallel-copy
--connection target
--table
--file <FILE_NAME>.csv
--workers <NUM_WORKERS>
--reporting-period 30s bash psql target \c <DATABASE_NAME> \COPY FROM <FILENAME>.csv CSV" bash export TARGET=postgres://tsdbadmin:<PASSWORD>@<HOST>:<PORT>/tsdb?sslmode=require bash SOURCE="mysql://<mysql_username>:<mysql_password>@<mysql_host>:<mysql_port>/<mysql_database>?sslmode=require" docker docker run -it ghcr.io/dimitri/pgloader:latest pgloader --no-ssl-cert-verification
"source"
"target" bash export TARGET=postgres://tsdbadmin:<PASSWORD>@<HOST>:<PORT>/tsdb?sslmode=require sql psql target -c "CREATE TABLE (
ts TIMESTAMPTZ NOT NULL,
location TEXT NOT NULL,
temperature DOUBLE PRECISION NULL
) WITH (timescaledb.hypertable, timescaledb.partition_column = 'ts');"
- TimescaleDB v2.19.3 and below:
Create a new regular table:
Convert the empty table to a hypertable:
In the following command, replace with the name of the table you just created, and `<COLUMN_NAME>` with the partitioning column in.
Set up a DuckDB connection to your service
In a terminal on the source machine with your Parquet files, start a new DuckDB interactive session:
Connect to your service in your DuckDB session:
target is the connection string you used to connect to your service using psql.
Import data from Parquet to your service
In DuckDB, upload the table data to your service
Where:
- ``: the hypertable you created to import data to -
<FILENAME>: the Parquet file to import data from
Exit the DuckDB session:
Verify the data was imported correctly into your service
In your psql session, view the data in ``:
And that is it, you have imported your data from a Parquet file to your Tiger Cloud service.
===== PAGE: https://docs.tigerdata.com/migrate/pg-dump-and-restore/ =====
Examples:
Example 1 (bash):
export TARGET=postgres://tsdbadmin:<PASSWORD>@<HOST>:<PORT>/tsdb?sslmode=requireExample 2 (sql):
psql target -c "CREATE TABLE ( \
ts TIMESTAMPTZ NOT NULL, \
location TEXT NOT NULL, \
temperature DOUBLE PRECISION NULL \
) WITH (timescaledb.hypertable, timescaledb.partition_column = 'ts');"
- TimescaleDB v2.19.3 and below:
1. Create a new regular table:Example 3 (unknown):
1. Convert the empty table to a hypertable:
In the following command, replace `` with the name of the table you just created, and `<COLUMN_NAME>` with the partitioning column in ``.Example 4 (unknown):
1. **Import your data**
In the folder containing your CSV files, either:
- Use [timescaledb-parallel-copy][install-parallel-copy]: