npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-duckdb

v0.1.5

Published

Node-red node for duckdb

Downloads

20

Readme

node-red-contrib-duckdb

Basic node red node for DuckDB.

Nodes

Database:

config database path, such as /tmp/duckdb.db. Or use :memory: Please read offical docs DuckDB Docs

Duckdb SQL Node (duckdb-sql)

Sql Option:

There are some sql execution options.

  • msg.sql exec: executes the sql query(ies) from input msg.sql, and does not return any result. DuckDB exec
  • sql exec: execute the sql query(ies) from code editor, and does not return any results. DuckDB exec
  • sql all: execute one sql query from code editor, and returns execution results. DuckDB all
  • sql each: execute one sql query from code editor, and returns row by row. DuckDB each
  • PS: execute the sql procedure statement from code editor, taken msg.params as parameters. msg.params must be an array. And does not return any results. example

Code Editor:

Input SQL queries.

DuckDB Function Node (duckdb func)

This node prototyped a node-red data transform node which read from database, transform data and then insert into database. The drive behind of this idea is that I think for the personal use all the data platform exist I knew are too heavy and difficult to setup and use. Data linage would also be difficult to achive.

This node provided an javascript code editor for transforming each row by function msg.proc and insert the processed data into database, also be able to output the result. This node also provided a template for user. The template is

msg.beforeProc = "CREATE TABLE <table name>(...);"
msg.procQuery = "SELECT * FROM <prev table name>";
msg.proc = function(row) {
    // transform row from proc query
    // return insert to new table
    return "INSERT INTO <table name> VALUES(" + JSON.stringify(Object.values(row)).slice(1, -1).replaceAll('"', '\'') + ");";
}

msg.afterProc = "SELECT * FROM <table name> LIMIT 10;";

Batch input defined the batch size of the process query. The value default to 100.

msg.beforeProc defined a sql that will be executed before the process function. Usually it should create a table to which new data insert. This field is optional.

msg.procQuery defined a sql that return data which will be processed from database. It should be a SELECT and MUST NOT end with ;. The code will add the limit and offset for batch process. This field is required for get data from db.

msg.proc defined a function which input is the row returned from sql defined in msg.procQuery. Function body should transform the data into some format and then return an INSERT query. The code running on background will handle the insert.

msg.afterProc defined a query which will be executed after all the rows being processed. The result of this query will be added to msg.payload and pass to the next node(s). This field is optional.

DuckDB Import Node (duckdb import)

A node for importing csv or parquet file to duckdb. User can pass advanced sql import to msg.import as input. DuckDB Import

Database:

config database path, such as /tmp/duckdb.db. Or use :memory:. Please read offical docs duck db docs

Import Type:

  • csv: load csv file from local and create table given file path and table name. DuckDB Import CSV
  • parquet: load parquet file from local and create table given file path and table name. DuckDB Import Parquet
  • msg.import: execute the import sql get from input msg.import . DuckDB Import SQLs

Table Name:

Input the create table name if choose csv or parquet.

File Path:

Input the csv or parquet file path.

DuckDB Export Node (dukdb export)

A node for exporting csv or parquet file to duckdb. User can pass advanced sql from msg.export as input. DuckDB Export

Database:

config database path, such as /tmp/duckdb.db. Or use :memory:. Please read offical docs duck db docs

Export Type:

Table Name:

Input the table name if choose parquet.

File Path:

Input the parquet file path.

Examples

1. All the basic sql nodes

example-flow

2. DuckDB Function Node

example-flow