@uwdata/mosaic-duckdb 0.2.0 → 0.3.0

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.
@@ -5,10 +5,10 @@ import { createWriteStream } from 'fs';
5
5
  const db = new DuckDB();
6
6
 
7
7
  // load CSV into duckdb
8
- await db.csv('data', process.argv[2]);
8
+ await db.exec(`CREATE TABLE data AS SELECT * FROM '${process.argv[2]}'`);
9
9
 
10
10
  // get output stream of arrow bytes
11
- const stream = await db.arrowBuffer('SELECT * FROM data');
11
+ const buf = await db.arrowBuffer('SELECT * FROM data');
12
12
 
13
13
  // determine the output stream
14
14
  const output = process.argv[3]
@@ -21,9 +21,4 @@ output.on('error', (error) => {
21
21
  });
22
22
 
23
23
  // write arrow bytes to output
24
- for await (const chunk of stream) {
25
- output.write(chunk);
26
- }
27
-
28
- // finish
29
- output.end(new Uint8Array(4));
24
+ output.end(buf);
package/bin/to-csv.js ADDED
@@ -0,0 +1,10 @@
1
+ #! /usr/bin/env node
2
+ import path from 'node:path';
3
+ import { DuckDB } from '../src/index.js';
4
+
5
+ const db = new DuckDB();
6
+ const input = process.argv[2];
7
+ const output = process.argv[3] ||
8
+ (path.basename(input, path.extname(input)) + '.csv');
9
+
10
+ await db.exec(`COPY (SELECT * FROM '${input}') TO '${output}' (FORMAT CSV, HEADER)`);
@@ -0,0 +1,10 @@
1
+ #! /usr/bin/env node
2
+ import path from 'node:path';
3
+ import { DuckDB } from '../src/index.js';
4
+
5
+ const db = new DuckDB();
6
+ const input = process.argv[2];
7
+ const output = process.argv[3] ||
8
+ (path.basename(input, path.extname(input)) + '.parquet');
9
+
10
+ await db.exec(`COPY (SELECT * FROM '${input}') TO '${output}' (FORMAT PARQUET)`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-duckdb",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A Promise-based DuckDB API and Node.js data server.",
5
5
  "keywords": [
6
6
  "duckdb",
@@ -18,6 +18,11 @@
18
18
  "type": "git",
19
19
  "url": "https://github.com/uwdata/mosaic.git"
20
20
  },
21
+ "bin": {
22
+ "to-arrow": "./bin/to-arrow.js",
23
+ "to-csv": "./bin/to-csv.js",
24
+ "to-parquet": "./bin/to-parquet.js"
25
+ },
21
26
  "scripts": {
22
27
  "lint": "eslint src test --ext .js",
23
28
  "server": "node bin/run-server.js",
@@ -25,8 +30,8 @@
25
30
  "prepublishOnly": "npm run test && npm run lint"
26
31
  },
27
32
  "dependencies": {
28
- "duckdb": "~0.7.1",
33
+ "duckdb": "~0.8.1",
29
34
  "ws": "^8.13.0"
30
35
  },
31
- "gitHead": "e53cd914c807f99aabe78dcbe618dd9543e2f438"
36
+ "gitHead": "a8dd23fed4c7a24c0a2ee5261d1aabe4239ce574"
32
37
  }