GlareDB is a fast SQL database for running analytics across distributed data.
This repository contains examples of using GlareDB Node.js bindings to analyze local files and join them with remote data in GlareDB Cloud. There is also a blog post accompanying this repository: https://glaredb.com/blog/node-bindings-announcement.
You can use these bindings with JavaScript and TypeScript.
- Node.js 20.10.0+ (LTS) https://nodejs.org/en
After cloning or downloading the repository, install dependencies:
npm install
Then, you can run the example:
npm run start
The example code queries a CSV file: src/students.csv
. The code is located in
src/main.ts
.
src/cloud.ts
contains a code example for joining data in your GlareDB Cloud
with local data in customer_report.csv
. To run this example:
-
Sign up for GlareDB Cloud. After signing in, you'll be dropped into the SQL Workspace, where you can explore and query your GlareDB data in the browser.
-
Click Create your first data source, which adds a query to the editor for adding a demo Postgres database.
-
Click Run to run the query. The Explorer on the left will now contain the Postgres database, called
my_pg
. You can explore the database. To ensure you're viewing the freshest schema, click the refresh icon at the top of the explorer.Tables have a 3-dot context menu. For example, click the 3-dot menu for the
customer
table, and then click SELECT query, which adds a query to select that table in the editor. -
Click the Connect button (next to Run) to open the Connection modal. Navigate to the Node.js tab and copy the Connection String. If you're a returning user and didn't store your password, click new password to create a new user/password pair. Passwords are displayed only once.
-
In
src/cloud.ts
, copy the Connection String into the variablecloudURL
. -
Run the code!
npm run start:cloud
Taking a closer look at
src/cloud.ts
, the query is performing aJOIN
on the Postgres data in GlareDB Cloud (my_pg
) with a local CSV filecustomer_report.csv
. This is the essence of GlareDB: query and access all of your data, easily.
- In addition to these NodeJS bindings, GlareDB has Python bindings
- You can also run GlareDB as an interactive CLI
- Connecting to GlareDB Cloud utilizes Hybrid Execution: queries are computed using both local and remote compute resources for optimal efficiency.