23 lines
588 B
Python
23 lines
588 B
Python
import sqlite3
|
|
import os
|
|
|
|
DB_PATH = "/sd/bordcomputer.db"
|
|
|
|
def init_db():
|
|
if not os.path.exists(DB_PATH):
|
|
conn = sqlite3.connect(DB_PATH)
|
|
c = conn.cursor()
|
|
c.execute('''
|
|
CREATE TABLE IF NOT EXISTS sensors (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
timestamp TEXT,
|
|
oil_temp REAL,
|
|
speed REAL,
|
|
latitude REAL,
|
|
longitude REAL,
|
|
distance REAL
|
|
)
|
|
''')
|
|
conn.commit()
|
|
conn.close()
|
|
print("Database created") |