dolphindb 3.0.218 → 3.0.220
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/README.zh.md +30 -0
- package/browser.d.ts +4 -0
- package/browser.js +10 -2
- package/browser.js.map +1 -1
- package/index.d.ts +4 -0
- package/index.js +10 -2
- package/index.js.map +1 -1
- package/package.json +5 -5
- package/test.js.map +1 -1
package/README.md
CHANGED
|
@@ -508,6 +508,37 @@ async upload (
|
|
|
508
508
|
): Promise<void>
|
|
509
509
|
```
|
|
510
510
|
|
|
511
|
+
|
|
512
|
+
### Upload and insert data into the table
|
|
513
|
+
```ts
|
|
514
|
+
// Load or create a table in the session corresponding to the connection
|
|
515
|
+
await ddb.execute('t = table(1..10 as id, take(["A001", "B001"], 10) as sym, rand(10.0, 10) as val)')
|
|
516
|
+
// await ddb.execute('t = loadTable(database("dfs://path-to-db"), "table_name")')
|
|
517
|
+
|
|
518
|
+
console.log(
|
|
519
|
+
'Number of rows inserted:',
|
|
520
|
+
// Use tableInsert to insert data
|
|
521
|
+
await ddb.invoke<number>(
|
|
522
|
+
'tableInsert',
|
|
523
|
+
[
|
|
524
|
+
't',
|
|
525
|
+
|
|
526
|
+
// Data
|
|
527
|
+
new DdbTable([
|
|
528
|
+
// First column
|
|
529
|
+
new DdbVectorInt([1, 2, 3]),
|
|
530
|
+
|
|
531
|
+
// Second column
|
|
532
|
+
new DdbVectorSymbol(['a', 'b', 'c']),
|
|
533
|
+
|
|
534
|
+
// The third column
|
|
535
|
+
new DdbVectorDouble([1.1, 1.2, 1.3]),
|
|
536
|
+
])
|
|
537
|
+
]
|
|
538
|
+
)
|
|
539
|
+
)
|
|
540
|
+
```
|
|
541
|
+
|
|
511
542
|
### Other Examples
|
|
512
543
|
|
|
513
544
|
```ts
|
package/README.zh.md
CHANGED
|
@@ -489,6 +489,36 @@ async upload (
|
|
|
489
489
|
```
|
|
490
490
|
|
|
491
491
|
|
|
492
|
+
### 向表中上传并插入数据
|
|
493
|
+
```ts
|
|
494
|
+
// 在连接对应的会话中加载或创建表
|
|
495
|
+
await ddb.execute('t = table(1..10 as id, take(["A001", "B001"], 10) as sym, rand(10.0, 10) as val)')
|
|
496
|
+
// await ddb.execute('t = loadTable(database("dfs://path-to-db"), "table_name")')
|
|
497
|
+
|
|
498
|
+
console.log(
|
|
499
|
+
'插入的行数:',
|
|
500
|
+
// 使用 tableInsert 插入数据
|
|
501
|
+
await ddb.invoke<number>(
|
|
502
|
+
'tableInsert',
|
|
503
|
+
[
|
|
504
|
+
't',
|
|
505
|
+
|
|
506
|
+
// 数据
|
|
507
|
+
new DdbTable([
|
|
508
|
+
// 第一列
|
|
509
|
+
new DdbVectorInt([1, 2, 3]),
|
|
510
|
+
|
|
511
|
+
// 第二列
|
|
512
|
+
new DdbVectorSymbol(['a', 'b', 'c']),
|
|
513
|
+
|
|
514
|
+
// 第三列
|
|
515
|
+
new DdbVectorDouble([1.1, 1.2, 1.3]),
|
|
516
|
+
])
|
|
517
|
+
]
|
|
518
|
+
)
|
|
519
|
+
)
|
|
520
|
+
```
|
|
521
|
+
|
|
492
522
|
### 其他例子
|
|
493
523
|
|
|
494
524
|
```ts
|
package/browser.d.ts
CHANGED
|
@@ -647,6 +647,7 @@ export interface DdbOptions {
|
|
|
647
647
|
username?: string;
|
|
648
648
|
password?: string;
|
|
649
649
|
python?: boolean;
|
|
650
|
+
kdb?: boolean;
|
|
650
651
|
sql?: SqlStandard;
|
|
651
652
|
streaming?: StreamingParams;
|
|
652
653
|
verbose?: boolean;
|
|
@@ -684,6 +685,8 @@ export declare class DDB {
|
|
|
684
685
|
password: string;
|
|
685
686
|
/** python session flag (2048) */
|
|
686
687
|
python: boolean;
|
|
688
|
+
/** kdb session flag (4096) */
|
|
689
|
+
kdb: boolean;
|
|
687
690
|
/** 表示本次会话执行的 SQL 标准 */
|
|
688
691
|
sql: SqlStandard;
|
|
689
692
|
/** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
|
|
@@ -720,6 +723,7 @@ export declare class DDB {
|
|
|
720
723
|
- username?: DolphinDB 登录用户名,默认 `'admin'` DolphinDB username, default `'admin'`
|
|
721
724
|
- password?: DolphinDB 登录密码,默认 `'123456'` DolphinDB password, default `'123456'`
|
|
722
725
|
- python?: 设置 python session flag,默认 `false` set python session flag, default `false`
|
|
726
|
+
- kdb?: 设置 kdb session flag,默认 `false` set kdb session flag, default `false`
|
|
723
727
|
- streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
|
|
724
728
|
- verbose?: 是否打印每个 rpc 的信息用于调试
|
|
725
729
|
- sql?: 设置当前会话执行的 sql 标准, 请使用 SqlStandard 枚举进行传参,默认 `DolphinDB`
|
package/browser.js
CHANGED
|
@@ -1862,7 +1862,7 @@ export function format(type, value, le, options = {}) {
|
|
|
1862
1862
|
}
|
|
1863
1863
|
case DdbType.complex: {
|
|
1864
1864
|
const [x, y] = value;
|
|
1865
|
-
return `${format(DdbType.double, x, le, options)}
|
|
1865
|
+
return `${format(DdbType.double, x, le, options)}${y >= 0 ? '+' : ''}${format(DdbType.double, y, le, options)}i`;
|
|
1866
1866
|
}
|
|
1867
1867
|
case DdbType.duration: {
|
|
1868
1868
|
const { data, unit } = value;
|
|
@@ -2822,6 +2822,8 @@ export class DDB {
|
|
|
2822
2822
|
password = '123456';
|
|
2823
2823
|
/** python session flag (2048) */
|
|
2824
2824
|
python = false;
|
|
2825
|
+
/** kdb session flag (4096) */
|
|
2826
|
+
kdb = false;
|
|
2825
2827
|
/** 表示本次会话执行的 SQL 标准 */
|
|
2826
2828
|
sql = SqlStandard.DolphinDB;
|
|
2827
2829
|
/** 是否为流数据连接,非流数据这个字段恒为 null Whether it is a streaming data connection, this field is always null for non-streaming data */
|
|
@@ -2861,6 +2863,7 @@ export class DDB {
|
|
|
2861
2863
|
- username?: DolphinDB 登录用户名,默认 `'admin'` DolphinDB username, default `'admin'`
|
|
2862
2864
|
- password?: DolphinDB 登录密码,默认 `'123456'` DolphinDB password, default `'123456'`
|
|
2863
2865
|
- python?: 设置 python session flag,默认 `false` set python session flag, default `false`
|
|
2866
|
+
- kdb?: 设置 kdb session flag,默认 `false` set kdb session flag, default `false`
|
|
2864
2867
|
- streaming?: 设置该选项后,该 WebSocket 连接只用于流数据 When this option is set, the WebSocket connection is only used for streaming data
|
|
2865
2868
|
- verbose?: 是否打印每个 rpc 的信息用于调试
|
|
2866
2869
|
- sql?: 设置当前会话执行的 sql 标准, 请使用 SqlStandard 枚举进行传参,默认 `DolphinDB`
|
|
@@ -2887,6 +2890,8 @@ export class DDB {
|
|
|
2887
2890
|
this.password = options.password;
|
|
2888
2891
|
if (options.python !== undefined)
|
|
2889
2892
|
this.python = options.python;
|
|
2893
|
+
if (options.kdb !== undefined)
|
|
2894
|
+
this.kdb = options.kdb;
|
|
2890
2895
|
if (options.sql !== undefined)
|
|
2891
2896
|
this.sql = options.sql;
|
|
2892
2897
|
if (options.streaming !== undefined)
|
|
@@ -2931,7 +2936,7 @@ export class DDB {
|
|
|
2931
2936
|
url.searchParams.set('filter', this.streaming.filters.expression.trim());
|
|
2932
2937
|
// 连接建立之前应该不会有别的调用占用 this.lwebsocket
|
|
2933
2938
|
this.lwebsocket.resource = await connect_websocket(url, {
|
|
2934
|
-
protocols: this.streaming ? ['streaming'] : this.python ? ['python'] : undefined,
|
|
2939
|
+
protocols: this.streaming ? ['streaming'] : this.python ? ['python'] : this.kdb ? ['kdb'] : undefined,
|
|
2935
2940
|
on_message: (buffer, websocket) => {
|
|
2936
2941
|
this.on_message(new Uint8Array(buffer), websocket);
|
|
2937
2942
|
},
|
|
@@ -3006,6 +3011,9 @@ export class DDB {
|
|
|
3006
3011
|
// python session
|
|
3007
3012
|
if (this.python)
|
|
3008
3013
|
flag += 2048;
|
|
3014
|
+
// kdb session
|
|
3015
|
+
if (this.kdb)
|
|
3016
|
+
flag += 4096;
|
|
3009
3017
|
// sql standrd
|
|
3010
3018
|
flag += 2 ** 19 * this.sql;
|
|
3011
3019
|
const options = [
|