EMWIU/clear_isitdown_database.py

22 lines
579 B
Python
Raw Permalink Normal View History

2018-12-25 00:58:46 +01:00
import sqlite3
import os
import sys
os.chdir(os.path.dirname(os.path.abspath(__file__)))
conn = sqlite3.connect("API.db")
cursor = conn.cursor()
cursor.execute(
"CREATE TABLE IF NOT EXISTS emwiu(id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, url TEXT, email TEXT, ip TEXT, starttime TEXT)"
)
conn.commit()
cursor.execute("""SELECT * FROM emwiu""")
rows = cursor.fetchall()
conn.close()
conn = sqlite3.connect("API.db")
cursor = conn.cursor()
for row in rows:
cursor.execute("DELETE FROM emwiu WHERE id =?", (row[0], ))
conn.commit()
conn.close()