#!/usr/bin/env python3

from time import sleep
from datetime import datetime

import sqlite3

conn = sqlite3.connect('./lightning.db')

c = conn.cursor()

# Create table
#c.execute('''CREATE TABLE events
#             (stormevent integer ,date text, elapsed real, topic text, payload integer)''')

# Insert a row of data

c.execute("INSERT INTO events VALUES (3,'2019-06-06 11:10:00',1055, 'ha32163/lightning/strikes',53)")
c.execute("INSERT INTO events VALUES (3,'2019-06-06 11:10:01',1056, 'ha32163/lightning/distance',15)")
c.execute("INSERT INTO events VALUES (3,'2019-06-06 11:12:00',1175, 'ha32163/lightning/strikes',54)")
c.execute("INSERT INTO events VALUES (3,'2019-06-06 11:12:01',1176, 'ha32163/lightning/distance',14)")
c.execute("INSERT INTO events VALUES (3,'2019-06-06 11:14:00',1295, 'ha32163/lightning/strikes',55)")
c.execute("INSERT INTO events VALUES (3,'2019-06-06 11:14:01',1296, 'ha32163/lightning/distance',8)")


#c.execute("INSERT INTO events VALUES (1,'2006-01-05 05:12:00',120,'test/ha32163/strike',53)")
#c.execute("INSERT INTO events VALUES (1,'2006-01-05 05:10:01',121, 'test/ha32163/distance',15)")
#c.execute("INSERT INTO events VALUES (1,'2006-01-05 05:14:00',240,'test/ha32163/strike',53)")
#c.execute("INSERT INTO events VALUES (1,'2006-01-05 05:10:01',241, 'test/ha32163/distance',15)")
#c.execute("INSERT INTO events VALUES (1,'2006-01-05 05:16:00',360,'test/ha32163/strike',54)")
#c.execute("INSERT INTO events VALUES (1,'2006-01-05 05:10:01',361, 'test/ha32163/distance',14)")

# Save (commit) the changes
conn.commit()

# We can also close the connection if we are done with it.
# Just be sure any changes have been committed or they will be lost.
conn.close()

