diff --git a/run_webreport.py b/run_webreport.py new file mode 100644 index 0000000..5e69755 --- /dev/null +++ b/run_webreport.py @@ -0,0 +1,3 @@ +import subprocess, sys + +subprocess.run([sys.executable, "-m", "streamlit", "run", "20 PrůzkumFotek/report.py"], cwd="U:/PycharmProjects/FotkyBuzalkovi") diff --git a/trash/test_db_connection.py b/trash/test_db_connection.py new file mode 100644 index 0000000..4e2c579 --- /dev/null +++ b/trash/test_db_connection.py @@ -0,0 +1,38 @@ +import psycopg2 +import sys + +try: + conn = psycopg2.connect( + host="192.168.1.76", + port=5432, + user="vladimir.buzalka", + password="Vlado7309208104++", + database="postgres" + ) + cursor = conn.cursor() + cursor.execute("SELECT version();") + version = cursor.fetchone() + print("[OK] PostgreSQL pripojeni uspesne!") + print(f"Verze: {version[0][:100]}") + + # Test MongoDB + try: + from pymongo import MongoClient + mongo_conn = MongoClient("mongodb://localhost:27017/", serverSelectionTimeoutMS=2000) + mongo_conn.admin.command('ping') + print("[OK] MongoDB dostupny") + except Exception as e: + print(f"[WARN] MongoDB: {str(e)[:50]}") + + # Test Redis + try: + import redis + redis_conn = redis.Redis(host='localhost', port=6379, socket_connect_timeout=2) + redis_conn.ping() + print("[OK] Redis dostupny") + except Exception as e: + print(f"[WARN] Redis: {str(e)[:50]}") + + conn.close() +except Exception as e: + print(f"[ERROR] PostgreSQL: {e}") diff --git a/trash/test_mongo.py b/trash/test_mongo.py new file mode 100644 index 0000000..ea21196 --- /dev/null +++ b/trash/test_mongo.py @@ -0,0 +1,58 @@ +from pymongo import MongoClient +from pymongo.errors import ServerSelectionTimeoutError + +try: + client = MongoClient( + "mongodb://192.168.1.76:27017/", + serverSelectionTimeoutMS=5000, + connectTimeoutMS=5000 + ) + + # Test pripojeni + client.admin.command('ping') + print("[OK] MongoDB pripojeni uspesne!") + + # Zobraz info + print(f"Server info: {client.server_info()}") + + # Vytvor databazi + db = client['fotky_buzalkovi'] + print(f"[OK] Databaze 'fotky_buzalkovi' vytvorena/existuje") + + # Vytvor kolekce s validaci + db.create_collection( + "photos", + validator={ + "$jsonSchema": { + "bsonType": "object", + "required": ["file_name", "file_path"], + "properties": { + "file_name": {"bsonType": "string"}, + "file_path": {"bsonType": "string"}, + "file_hash": {"bsonType": "string"}, + "camera": {"bsonType": "string"}, + "taken_at": {"bsonType": "date"}, + "width": {"bsonType": "int"}, + "height": {"bsonType": "int"}, + "file_size": {"bsonType": "int"}, + "exif": {"bsonType": "object"}, + "tags": {"bsonType": "array"} + } + } + } + ) + print("[OK] Kolekce 'photos' vytvorena") + + # Vytvor indexy + db.photos.create_index("file_hash", unique=True) + db.photos.create_index("taken_at") + db.photos.create_index("camera") + db.photos.create_index("tags") + print("[OK] Indexy vytvoreny") + + client.close() + +except ServerSelectionTimeoutError as e: + print(f"[ERROR] Timeout - MongoDB neni dostupny: {e}") +except Exception as e: + print(f"[ERROR] {e}")