initial
This commit is contained in:
23
database.py
Normal file
23
database.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user