From a990f7b39416eb4587515ea768725f6dd72506c3 Mon Sep 17 00:00:00 2001 From: Vladimir Buzalka Date: Mon, 19 Jan 2026 21:05:28 +0100 Subject: [PATCH] git --- Systematicky/01 CozbyvádotáhnoutdleMysql.py | 64 +++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Systematicky/01 CozbyvádotáhnoutdleMysql.py diff --git a/Systematicky/01 CozbyvádotáhnoutdleMysql.py b/Systematicky/01 CozbyvádotáhnoutdleMysql.py new file mode 100644 index 0000000..828351c --- /dev/null +++ b/Systematicky/01 CozbyvádotáhnoutdleMysql.py @@ -0,0 +1,64 @@ +import pymysql +import pymysql.cursors + + +def get_unfinished_torrents(): + # Konfigurace připojení + connection_config = { + 'host': '192.168.1.76', + 'user': 'root', + 'password': 'Vlado9674+', + 'database': 'torrents', + 'port': 3307, + 'cursorclass': pymysql.cursors.DictCursor # Vrací výsledky jako slovník + } + + try: + # Navázání spojení + connection = pymysql.connect(**connection_config) + + with connection.cursor() as cursor: + # SQL Dotaz + sql = """ + SELECT + title_visible, + qb_progress, + qb_state, + size_pretty, + added_datetime + FROM torrents + WHERE qb_added = 1 + AND qb_progress < 1 + AND qb_state NOT IN ('seeding', 'uploading', 'stalledUP', 'pausedUP', 'completed') + ORDER BY qb_progress DESC; + """ + + cursor.execute(sql) + results = cursor.fetchall() + + print(f"\n--- NEDOKONČENÉ TORRENTY (Port {connection_config['port']}) ---") + + if not results: + print("Vše je hotovo nebo nic neběží.") + else: + for row in results: + # Předpokládáme, že qb_progress je float (0.0 až 1.0) + progress_pct = row['qb_progress'] * 100 + + print(f"Torrent: {row['title_visible']}") + print(f"Stav: {row['qb_state']}") + print(f"Pokrok: {progress_pct:.2f}%") + print(f"Velikost: {row['size_pretty']}") + print("-" * 40) + + except pymysql.MySQLError as e: + print(f"Chyba při komunikaci s DB: {e}") + + finally: + if 'connection' in locals(): + connection.close() + print("Spojení s databází bylo uzavřeno.") + + +if __name__ == "__main__": + get_unfinished_torrents() \ No newline at end of file