''' ____ ___ _ _ _ / ___| / _ \| | (_) |_ ___ \___ \| | | | | | | __/ _ \ ___) | |_| | |___| | || __/ |____/ \__\_\_____|_|\__\___| Script to create a sqlite database /usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/create_db.py ''' import sqlite3 # Connect to (or create if not existent) the database conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db") cursor = conn.cursor() # Create a table 1 cursor.execute(""" CREATE TABLE IF NOT EXISTS data_NPM ( timestamp TEXT, PM1 REAL, PM25 REAL, PM10 REAL, temp_npm REAL, hum_npm REAL ) """) # Create a table 2 cursor.execute(""" CREATE TABLE IF NOT EXISTS data_BME280 ( timestamp TEXT, temperature REAL, humidity REAL, pressure REAL ) """) # Create a table 3 cursor.execute(""" CREATE TABLE IF NOT EXISTS data_envea ( timestamp TEXT, no2 REAL, h2s REAL, nh3 REAL, co REAL, o3 REAL ) """) # Create a table 4 cursor.execute(""" CREATE TABLE IF NOT EXISTS data_NPM_5channels ( timestamp TEXT, PM_ch1 INTEGER, PM_ch2 INTEGER, PM_ch3 INTEGER, PM_ch4 INTEGER, PM_ch5 INTEGER ) """) # Commit and close the connection conn.commit() conn.close() print("Database and table created successfully!")