时序数据库 quasardb 入门

到:https://download.quasar.ai/quasardb/3.9/3.9.9/server/

下载最新版: https://download.quasar.ai/quasardb/3.9/3.9.9/server/qdb-3.9.9-windows-64bit-setup.exe

然后安装,记得先不勾选安全连接。安装成功以后,自己去操作下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
>"C:\Program Files\quasardb\bin\qdbsh.exe"
quasardb shell version 3.9.9 build fc2829ecc 2021-07-01 09:13:49 +0200
Copyright (c) 2009-2021, quasardb SAS. All rights reserved.
 
Need some help? Check out our documentation here:  https://doc.quasardb.net
 
qdbsh > CREATE TABLE stocks (close DOUBLE)
 
qdbsh > INSERT INTO stocks ($timestamp, close) VALUES (2017-01-01, 1.0), (2017-01-02, 2.0), (2017-01-03, 3.0)
 
qdbsh > select * from stocks in range(2017-01-01, 2017-01-10)
$timestamp                       $table            close
---------------------------------------------------------
2017-01-01T00:00:00.000000000Z   stocks                1
2017-01-02T00:00:00.000000000Z   stocks                2
2017-01-03T00:00:00.000000000Z   stocks                3
 
Returned 3 rows in 6,441 us
Scanned 3 points in 6,441 us (465 rows/sec)
 
qdbsh > show stocks
Shard size: 86400000 ms
2 columns
 0. timestamp index
 1. close - double (0)

  

为了使用C api操作数据:

需要先下载api:

https://download.quasar.ai/quasardb/3.9/3.9.9/api/c/

操作代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma comment(lib, "D:\\source\\qdb-3.9.9-windows-64bit-c-api\\lib\\qdb_api.lib")
 
#include <qdb/client.h>
#include <qdb/tag.h>
#include <qdb/ts.h>
#include <stdio.h>
 
#define EXIT_FAILURE 1
 
int main() {
    // We first need to open a handle, which is is the memory structure that
    // QuasarDB uses to maintain connection state.
    qdb_handle_t handle;
    qdb_error_t error = qdb_open(&handle, qdb_p_tcp);
    if (QDB_FAILURE(error)) return EXIT_FAILURE;
 
    // Now that we have opened the handle, we can tell it to establish a connection
    // with the cluster.
    error = qdb_connect(handle, "qdb://127.0.0.1:2836");
    if (QDB_FAILURE(error)) {
        printf("Connect db failed!Error code:%d\n", error);
        return EXIT_FAILURE;
    }
    // Initialize our columns definitions
    const qdb_ts_column_info_t columns[3] = {
        {.name = "open",.type = qdb_ts_column_double},  //
        {.name = "close",.type = qdb_ts_column_double}, //
        {.name = "volume",.type = qdb_ts_column_int64}  //
    };
    const int columns_count = sizeof(columns) / sizeof(qdb_ts_column_info_t);
 
    // Now create the table with the default shard size
    qdb_error_t error2 = qdb_ts_create(handle, "stocks4test", qdb_d_default_shard_size, columns, columns_count);
    if (QDB_FAILURE(error2)) {
        printf("Insert data failed! Error code: %d\n", error2);
        return EXIT_FAILURE;
    }
    printf("Insert data success!\n");
}

  

可以看到操作成功!

1
2
3
4
5
6
7
qdbsh > show stocks4test
Shard size: 86400000 ms
4 columns
 0. timestamp index
 1. open - double (0)
 2. close - double (1)
 3. volume - int64 (2)
posted @   bonelee  阅读(88)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
历史上的今天:
2020-06-28 spark上的深度学习——按照雅虎的做法,本质上就是rdd.pipe,推理部分直接代理给tensorflow
2019-06-28 163data.com.cn data
2018-06-28 leetcode 415. Add Strings
2018-06-28 HTTP metadata数据
2018-06-28 CC攻击工具list
2017-06-28 PAC学习框架
2017-06-28 DNS通道检测 国外学术界研究情况——研究方法:基于流量,使用机器学习分类算法居多,也有使用聚类算法的;此外使用域名zif low也有
点击右上角即可分享
微信分享提示