21 lines
654 B
Text
21 lines
654 B
Text
|
#!/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)
|