You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
800 B
37 lines
800 B
import collections |
|
|
|
Subscription = collections.namedtuple( |
|
"Subscription", |
|
[ |
|
"id", |
|
"phone", |
|
"icao", |
|
"description", |
|
"last_seen", |
|
], |
|
) |
|
|
|
|
|
def load_database(file_name): |
|
con = sqlite3.connect(file_name) |
|
|
|
con.execute( |
|
"CREATE TABLE IF NOT EXISTS subscriptions(phone VARCHAR, icao VARCHAR, description VARCHAR, last_seen INTEGER)" |
|
) |
|
con.commit() |
|
|
|
return con |
|
|
|
|
|
def update_last_seen_time(con, sub_id): |
|
con.execute( |
|
"UPDATE subscriptions SET last_seen = ? WHERE rowid = ?", |
|
(time.time(), sub_id), |
|
) |
|
|
|
|
|
def get_subscriptions(con): |
|
for subscription in con.execute( |
|
"SELECT rowid, phone, icao, description, last_seen FROM subscriptions" |
|
).fetchall(): |
|
return Subscription(*subscription)
|
|
|