notebookVb

This commit is contained in:
administrator
2026-05-24 07:59:38 +02:00
parent 7e05384c1f
commit 4d8888a598
3 changed files with 99 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
import subprocess, sys
subprocess.run([sys.executable, "-m", "streamlit", "run", "20 PrůzkumFotek/report.py"], cwd="U:/PycharmProjects/FotkyBuzalkovi")
+38
View File
@@ -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}")
+58
View File
@@ -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}")