21 lines
562 B
Python
21 lines
562 B
Python
import sys
|
|
import time
|
|
import sqlite3
|
|
|
|
try:
|
|
amount_of_deals = sys.argv[1]
|
|
except Exception as e:
|
|
print(e)
|
|
print("Usage: python3 last_n_deals.py int")
|
|
sys.exit()
|
|
|
|
connection = sqlite3.connect('profits_database.db')
|
|
cursor = connection.cursor()
|
|
cursor.execute(f'SELECT * FROM profits_table ORDER BY timestamp DESC LIMIT {amount_of_deals}')
|
|
deals = cursor.fetchall()
|
|
connection.close()
|
|
|
|
|
|
for line in deals[::-1]:
|
|
human_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(line[0])))
|
|
print(human_time,line[1],round(line[2],2),line[3]) |