update
This commit is contained in:
27
sqlite/create_db.py
Normal file
27
sqlite/create_db.py
Normal file
@@ -0,0 +1,27 @@
|
||||
'''
|
||||
Script to create a sqlite database
|
||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/create_db.py
|
||||
|
||||
'''
|
||||
|
||||
import sqlite3
|
||||
|
||||
# Connect to (or create) the database
|
||||
conn = sqlite3.connect("/var/www/nebuleair_pro_4g/sqlite/sensors.db")
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Create a table for storing sensor data
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS data (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
sensor TEXT,
|
||||
value REAL
|
||||
)
|
||||
""")
|
||||
|
||||
# Commit and close the connection
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
print("Database and table created successfully!")
|
||||
Reference in New Issue
Block a user