forked from PX4/flight_review
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_db_entry.py
More file actions
executable file
·33 lines (23 loc) · 875 Bytes
/
delete_db_entry.py
File metadata and controls
executable file
·33 lines (23 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env python3
# Script to remove a single DB entry
import sqlite3 as lite
import sys
import os
import argparse
from plot_app.config import get_db_filename
parser = argparse.ArgumentParser(description='Remove a DB entry (but not the log file)')
parser.add_argument('log_id', metavar='log-id', action='store', nargs='+',
help='log id to remove (eg. 8600ac02-cf06-4650-bdd5-7d27ea081852)')
args = parser.parse_args()
con = lite.connect(get_db_filename())
with con:
cur = con.cursor()
for log_id in args.log_id:
print('Removing '+log_id)
cur.execute("DELETE FROM LogsGenerated WHERE Id = ?", (log_id,))
cur.execute("DELETE FROM Logs WHERE Id = ?", (log_id,))
num_deleted = cur.rowcount
if num_deleted != 1:
print('Error: not found ({})'.format(num_deleted))
con.commit()
con.close()