This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Aligns with logged columns in config.yaml | |
-- Update the first line with your table name | |
CREATE TABLE "air_quality_log_test/air_quality"."pm_measurements" ( | |
"datetime" timestamp with time zone, | |
"location" text, | |
"sensor_id" integer, | |
"pm_2_5" real, | |
"pm_10" real | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parse_value(message, byte_order, start_byte, num_bytes, scale=None): | |
"""Returns a number from a sequence of bytes.""" | |
value = message[start_byte: start_byte + num_bytes] | |
value = int.from_bytes(value, byteorder=byte_order) | |
value = value * scale if scale else value | |
return value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
def create_record(sample, measurement_config, period): | |
"""Create a record for insertion to a database.""" | |
record = {'location': 'outside of house'} | |
record['sensor_id'] = parse_value(sample[0], 'little', [6, 2]) | |
record['datetime'] = str(datetime.utcnow()) | |
for measurement, parse_args in config['measurements'].items(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
ser = serial.Serial('/dev/ttyUSB0') | |
message = ser.read(10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Client } = require('pg'); | |
const client = new Client({ | |
database: 'bitdotio', | |
host: 'db.bit.io', | |
port: 5432, | |
user: '<YOUR USERNAME HERE>', | |
password: '<YOUR PASSWORD HERE>' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Activate the venv and navigate to the location of main.py | |
source venv/bin/activate | |
cd simple_pipeline | |
# Uncomment the line below if you would like to re-run the population data pipeline | |
# The population data is only updated annually by the Census Bureau | |
# python main.py -local_source -name acs_population_counties \ | |
# acs_5yr_population_data.csv bitdotio/simple_pipeline.population_counties | |
python main.py -name nyt_cases_counties \ | |
'https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv' \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS "bitdotio/simple_pipeline"."ca_covid_data_join" ( | |
date date, | |
county TEXT, | |
fips TEXT, | |
cases INTEGER, | |
deaths INTEGER, | |
pct_vaccinations_complete REAL, | |
num_vaccinations_complete INTEGER, | |
total_population INTEGER, | |
population_16plus INTEGER, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python main.py -name <TRANSFORM_FUNCTION_NAME> '<DATA_SOURCE_URL>' '<USERNAME/REPO_NAME.DESTINATION_TABLE_NAME>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 09 * * * cd ~/Documents/simple_pipeline && ./scheduled_run.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Activate the venv and navigate to the location of main.py | |
source venv/bin/activate | |
cd simple_pipeline | |
# Uncomment the line below if you would like to re-run the population data pipeline | |
# The population data is only updated annually by the Census Bureau | |
# python main.py -local_source -name acs_population_counties \ | |
# acs_5yr_population_data.csv bitdotio/simple_pipeline.population_counties | |
python main.py -name nyt_cases_counties \ | |
'https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv' \ |