Код:
import sqlite3
import psutil
db = sqlite3.connect('server.db')
sql = db.cursor()
sql.execute("CREATE TABLE IF NOT EXISTS users(razdels varchar, nedavnie varchar, izbranie varchar, process_list varchar)")
db.commit()
sql.execute("SELECT process_list FROM users")
for proc in psutil.process_iter(["name"]):
a = proc.info["name"]
print(a)
if sql.fetchone() is None:
sql.execute("""INSERT INTO users (process_list) VALUES (?) """, (a,))
db.commit()
for value in sql.execute("SELECT * FROM users"):
print(value)