dns-ops/dns-rest-api1.sunet.se/overlay/usr/sbin/knot_lastlogin

21 lines
654 B
Text
Raw Normal View History

2025-03-05 15:34:55 +01:00
#!/usr/bin/env python3
import sqlite3
try:
with sqlite3.connect('/var/lib/knot_rest/database.db') as conn:
cur = conn.cursor()
cur.execute('select username, description, logged_in from user')
rows = cur.fetchall()
for row in rows:
username = row[0]
description = row[1]
if description == None:
description = "(no description)"
lastlogin = row[2]
if lastlogin == None:
lastlogin = "***never logged in***"
print(f"{username:<27}{description:<27}{lastlogin:<23}")
except sqlite3.OperationalError as e:
print(e)