Lindorm-cli is a lightweight command-line interface (CLI) for connecting to and managing Lindorm databases. Use it to run SQL operations against Lindorm Time Series Database (LindormTSDB) — create tables, write data, and query results — without installing a full SDK.
Prerequisites
Before you begin, ensure that you have:
Added your client's IP address to the Lindorm whitelist. See Set a whitelist.
Step 1: Install Lindorm-cli
Download the Lindorm-cli package for your operating system. On Linux, you can also download directly from the terminal:
Use the SHA256 checksums in the table to verify the integrity of the downloaded package.
Operating system
Download link
SHA256
Linux
3a9ee33e24769cf47b3a90c3a1bba29d26f8aede7a64dbc13ea1f4f5426f04e4
Linux (arm64)
bc723d4a3a14a85c973c7082a56bb4934a40d2b9cccd72b5767352b8c334ce19
macOS (Intel)
34efd3f43a700e1fea72ee5e5933b9df3cf624569bcf59a2f8a6752dc7faab6c
macOS (Apple silicon)
0be9b346404a37d953714377b59f06b6492ff9c4e46dba4d5bf07c390ee284ad
Windows
54a447f263b93b158533f7ccd542cbf52e42fb66ce287d38065a798b7801fc48
# x86_64 wget https://tsdbtools.oss-cn-hangzhou.aliyuncs.com/lindorm-cli-linux-latest.tar.gz # arm64 wget https://tsdbtools.oss-cn-hangzhou.aliyuncs.com/lindorm-cli-linux-arm64-latest.tar.gzExtract the package. On Linux or macOS:
tar zxvf lindorm-cli-linux-latest.tar.gzAfter extraction, the
lindorm-clibinary is in thelindorm-cli-linux-latestfolder. (Optional) Add the binary to your$PATHso you can runlindorm-clifrom any directory. If you skip this step, run the binary using its full path (for example,./lindorm-cli).
Step 2: Connect to LindormTSDB
Linux and macOS
Navigate to the folder containing the
lindorm-clibinary.cd <folder where lindorm-cli is stored>Connect to LindormTSDB.
Parameters:
Parameter
Required
Default
Description
-urlYes
—
The LindormTSDB SQL URL. Example:
jdbc:lindorm:tsdb:url=http://ld-bp12pc23yfb3*****-proxy-tsdb-pub.lindorm.rds.aliyuncs.com:8242. You can also use a LindormTSDB HTTP endpoint. See View endpoints.-usernameNo
(none)
The username for LindormTSDB. Omit if user authentication is not enabled. See User and permission management.
-passwordNo
(none)
The password for LindormTSDB. Omit if user authentication is not enabled. To reset your password, see Change the password.
-databaseNo
defaultThe database to connect to. To switch databases after connecting, run
use <database name>../lindorm-cli -url <LindormTSDB SQL URL> -username <username> -password <password> -database <database name>Example:
./lindorm-cli -url jdbc:lindorm:tsdb:url=http://ld-4xo90g5i370cu****-proxy-tsdb.lindorm.rds.aliyuncs.com:8242 -username user -password test -database defaultA successful connection returns the Lindorm-cli version:
lindorm-cli version: 1.0.xxEnter
helpto see available commands.
Windows
Method 1: Command prompt
Open Command Prompt (CMD) and navigate to the folder containing
lindorm-cli.exe.cd <folder where lindorm-cli.exe is stored>Connect to LindormTSDB.
lindorm-cli -url <LindormTSDB SQL URL> -username <username> -password <password> -database <database name>A successful connection returns:
Connected to jdbc:lindorm:tsdb:url=http://****-proxy-tsdb-pub.lindorm.rds.aliyuncs.com:8242 lindorm-cli version: 1.0.xx
Method 2: Double-click
Double-click Lindorm-cli.exe, then run:
connect <LindormTSDB SQL URL> <username> <password> -database <database name>If the connection succeeds, no output is returned.
Step 3: Use LindormTSDB
The following examples use a sensor table that records temperature and humidity readings from IoT devices.
Create a table
LindormTSDB uses SQL syntax for DDL. Two constraints apply when creating a time series table:
The timestamp column must be named
time. It stores timestamps in milliseconds (ms).Specify a
PRIMARY KEYto uniquely identify a data source — for example, a device ID in Internet of Things (IoT) scenarios, a vehicle identifier in Internet of Vehicles (IoV) scenarios, or anip:portpair in monitoring scenarios.
The Basic Edition does not support primary keys.
Create the
sensortable.CREATE TABLE sensor ( device_id VARCHAR NOT NULL, region VARCHAR NOT NULL, time TIMESTAMP NOT NULL, temperature DOUBLE, humidity BIGINT, PRIMARY KEY(device_id, region, time) );Verify the table was created.
SHOW TABLES;Expected output:
+-------------------+ | Tables_In_default | +-------------------+ | sensor | +-------------------+Inspect the table schema.
DESCRIBE TABLE sensor;Expected output:
+-------------+-----------+------------+------------+--------------+ | columnName | typeName | columnKind | primaryKey | partitionTag | +-------------+-----------+------------+------------+--------------+ | device_id | VARCHAR | TAG | true | true | | region | VARCHAR | TAG | true | true | | time | TIMESTAMP | TIMESTAMP | true | false | | temperature | DOUBLE | FIELD | false | false | | humidity | BIGINT | FIELD | false | false | +-------------+-----------+------------+------------+--------------+
Write data
Data points with the same tags and timestamp are treated as the same data point. Later writes overwrite earlier ones.
Write individual rows:
INSERT INTO sensor (device_id, region, time, temperature, humidity) VALUES('F07A1260','north-cn','2021-04-22 15:33:00',12.1,45);
INSERT INTO sensor (device_id, region, time, temperature, humidity) VALUES('F07A1260','north-cn','2021-04-22 15:33:10',13.2,47);
INSERT INTO sensor (device_id, region, time, temperature, humidity) VALUES('F07A1260','north-cn','2021-04-22 15:33:20',10.6,46);
INSERT INTO sensor (device_id, region, time, temperature, humidity) VALUES('F07A1261','south-cn','2021-04-22 15:33:00',18.1,44);
INSERT INTO sensor (device_id, region, time, temperature, humidity) VALUES('F07A1261','south-cn','2021-04-22 15:33:10',19.7,44);Or write multiple rows in a single statement:
INSERT INTO sensor (device_id, region, time, temperature, humidity)
VALUES ('F07A1260','north-cn','2021-04-22 15:33:00',12.1,45),
('F07A1260','north-cn','2021-04-22 15:33:10',13.2,47),
('F07A1260','north-cn','2021-04-22 15:33:20',10.6,46),
('F07A1261','south-cn','2021-04-22 15:33:00',18.1,44),
('F07A1261','south-cn','2021-04-22 15:33:10',19.7,44);Query data
Conditional query
Query readings for device F07A1260 between 2021-04-22 15:33:00 and 2021-04-22 15:33:20:
SELECT device_id,region,time,temperature,humidity FROM sensor WHERE device_id = 'F07A1260' AND time >= '2021-04-22 15:33:00' AND time <= '2021-04-22 15:33:20';Result:
+-----------+----------+---------------------------+-------------+----------+
| device_id | region | time | temperature | humidity |
+-----------+----------+---------------------------+-------------+----------+
| F07A1260 | north-cn | 2021-04-22T15:33:00+08:00 | 12.1 | 45 |
| F07A1260 | north-cn | 2021-04-22T15:33:10+08:00 | 13.2 | 47 |
| F07A1260 | north-cn | 2021-04-22T15:33:20+08:00 | 10.6 | 46 |
+-----------+----------+---------------------------+-------------+----------+Downsampling query
A downsampling query aggregates values within fixed time intervals to reduce the number of data points in the result set. Use SAMPLE BY to set the interval.
Get the maximum temperature for device F07A1260 over a 20-second window:
SELECT device_id,region,time,max(temperature) AS max_temperature FROM sensor WHERE device_id = 'F07A1260' AND time >= '2021-04-22 15:33:00' AND time <= '2021-04-22 15:33:20' SAMPLE BY 20s;Result:
+-----------+----------+---------------------------+-----------------+
| device_id | region | time | max_temperature |
+-----------+----------+---------------------------+-----------------+
| F07A1260 | north-cn | 2021-04-22T15:33:00+08:00 | 13.2 |
| F07A1260 | north-cn | 2021-04-22T15:33:20+08:00 | 10.6 |
+-----------+----------+---------------------------+-----------------+Aggregate query
Calculate the maximum temperature per region across all devices:
SELECT region,max(temperature) AS max_temperature FROM sensor WHERE time >= '2021-04-22 15:33:00' AND time <= '2021-04-22 15:33:20' GROUP BY region;Result:
+----------+-----------------+
| region | max_temperature |
+----------+-----------------+
| north-cn | 13.2 |
| south-cn | 19.7 |
+----------+-----------------+Common Lindorm-cli commands
Command | Description |
| Lists available commands. |
| Connects to a server. |
| Sets the time display format. Valid values: |
| Switches to a different database in the current session. |
| Disconnects and exits Lindorm-cli. |
FAQ
Why is my query returning no results after writing data?
Run DESCRIBE DATABASE <database name> and check whether a time to live (TTL) is configured. If the data's age exceeds the TTL, LindormTSDB automatically deletes it and the data no longer appears in query results.
Can Lindorm-cli import and export CSV files?
For small datasets, Lindorm-cli supports CSV import and export. Contact Lindorm technical support (DingTalk group: s0s3eg3) for this feature.
For large datasets, use DataX to import data. Exporting large-scale data is not supported.