Li

Lightweight data analytics using SQLite, Bash and DuckDB

Hacker News

Lightweight data analytics using SQLite, Bash and DuckDB

Over the last 12 months, in parallel to using Google BigQuery, I have built my own processing pipeline using SQLite and DuckDB. What amazes me is that it works surprisingly well and costs much less than using BigQuery. Roughly speaking, here's what I do: A SQLite database receives IoT sensor data via a very simple PHP function. I currently use the FlightPHP framework for this. The data is written to a table within the SQLite database (WAL mode activated) and states are updated by the machines using triggers. Example of a trigger CREATE TRIGGER message_added AFTER INSERT ON messages BEGIN INSERT OR REPLACE INTO states VALUES ( new.id, new.status, new.time_stamp, new.current_present, new.voltage_present) This allows me to query the current status of a machine in real time. To do this, I again use a simple PHP function that provides the data via SSE. In the frontend, a simple Javascript method (plain vanilla JS) retrieves the JSON data and updates the HTML in real time. const source_realtime = new EventSource("https://myapi/sse_realtime_json"); source_realtime.onmessage = function(event) { var json = JSON.parse(event.data); }; For a historical analysis - for example over 24 months - I create a CSV export from the SQLite database and convert the CSV files into Parquet format. I use a simple BASH script that I execute regularly via CronJob. Here is an excerpt # Loop through the arrays and export each table to a CSV, then convert it to a Parquet file and load into the DuckDB database for (( i=0; i<${arrayLength}; i++ )); do db=${databases[$i]} table=${tables[$i]} echo "Processing $db - $table" # Export the SQLite table to a CSV file sqlite3 -header -csv $db "SELECT * FROM $table;" > parquet/$table.csv # Convert the CSV file to a Parquet file using DuckDB $duckdb_executable $duckdb_database <<EOF -- Set configurations SET memory_limit='2GB'; SET threads TO 2; SET enable_progress_bar=true; COPY (SELECT * FROM read_csv_auto('parquet/$table.csv', header=True)) TO 'parquet/$table.parquet' (FORMAT 'PARQUET', CODEC 'ZSTD'); CREATE TABLE $table AS SELECT * FROM read_parquet('parquet/$table.parquet'); EOF Now finally my question: Am I overlooking something? This little system works well for currently 15 million events per month. No outtages, nothing like that. I read so much about fancy data pipelines, reactive frontend dashboards, lambda functions ... Somehow my system feels "too simple". So I'm sharing it with you in the hope of getting feedback.

Share card

Actual performance

5points
6comments
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Indie HackersFits the IH revenue-focused audience · Strong signals: para · Missing: supports, reddit linkedin, podcasting
74%74% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Product HuntOn track for Day 1 leaderboard · Strong signals: mac, google, new · Missing: agents, macos, agent
68%68% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: ide, pipe, io · Missing: https docs, excited, just released
64%64% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRLess likely to generate early MRR · Strong signals: month, google, para · Missing: mobile apps, ios, personal
38%38% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
37%37% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Strong signals: arr, active · Missing: mrr, revenue, profit
16%16% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Strong signals: real time · Missing: web3, chat, crypto
1%1% predicted probability of success on BetaList, based on ML models trained on real launch data.

Incorrect prediction on native model

Similar products

NS
NStack – Typed, composable microservices for data analytics62%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

NStack – Typed, composable microservices for data analytics

Hacker News30
SatData
SatData44%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

satellites data analytics

Indie Hackers1saas
Mo
MotherDuck – a serverless data analytics platform powered by DuckDB83%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

MotherDuck – a serverless data analytics platform powered by DuckDB

Hacker News17
Yanzu Data
Yanzu Data42%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Data Analytics and Management

Indie Hackers2analytics
DeepDive
DeepDive80%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Data Analytics for Marketing Agenices

Indie Hackers2analytics
RowSpeak
RowSpeak38%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

AI-Powered data analytics

Indie Hackers1$2,000/moai
Da
Data Analytics on Programmer Jobs53%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Data Analytics on Programmer Jobs

Hacker News2
stress concentration tomography
stress concentration tomography34%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

data analytics

Indie Hackers
Qreuz
Qreuz52%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Add consent-free data to your analytics.

Indie Hackers4advertising
AirROI
AirROI85%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Democratize Airbnb STR Data Analytics

Indie Hackers1analytics