sudo docker compose up -d
python3 /opt/service_finder/backend/scrapers/vehicle_master_data.py
pip install httpx beautifulsoup4 sqlalchemy asyncpg python-dotenv
ping service_finder_api -c 4
docker ps
cd ..
docker ps
ls
cd project
ls
cat requirements.txt
docker network inspect service_finder_net
cd ..
docker network inspect service_finder_net
ping service_finder_api -c 4
ls
cd projekt
ping service_finder_api -c 4
API_IP=$(sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' service_finder_api)
curl http://$API_IP:8000/vehicles
API_IP=$(sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' service_finder_api)
sudo apt update
sudo apt install -y python3-pip
~pip3 install httpx beautifulsoup4 sqlalchemy asyncpg python-dotenv
pip3 install httpx beautifulsoup4 sqlalchemy asyncpg python-dotenv
python3 /opt/service_finder/backend/scrapers/vehicle_master_data.py
python3 backend/scrapers/vehicle_master_data.py
pip3 install httpx beautifulsoup4 sqlalchemy asyncpg python-dotenv
python3 backend/scrapers/vehicle_master_data.py
pip3 install httpx beautifulsoup4 sqlalchemy asyncpg python-dotenv --break-system-packages
python3 backend/scrapers/vehicle_master_data.py
ls
cd backend
ls
cd scrapers
ls
rm -f vehicle_master_data.py
sudo rm -f vehicle_master_data.py
ls
nano vehicle_master_data.py
sudo chown -R $USER:$USER .
cd ..
sudo chown -R $USER:$USER .
cat <<EOF > backend/scrapers/vehicle_master_data.py
import asyncio
import os
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy import text
from dotenv import load_dotenv

# .env betöltése
load_dotenv(os.path.join(os.path.dirname(__file__), '../../.env'))

DATABASE_URL = os.getenv("DATABASE_URL")
if not DATABASE_URL:
    print("HIBA: Nem találom a DATABASE_URL-t a .env fájlban!")
    exit(1)

# Adatkészlet
INITIAL_DATA = {
    "BMW": ["3 Series", "5 Series", "X5", "R 1250 GS (Motor)"],
    "Toyota": ["Corolla", "Yaris", "RAV4", "Hilux"],
    "Volkswagen": ["Golf", "Passat", "Tiguan", "Polo"],
    "Honda": ["Civic", "CR-V", "CB500X (Motor)", "Africa Twin (Motor)"],
    "Audi": ["A3", "A4", "A6", "Q5"],
    "Mercedes-Benz": ["C-Class", "E-Class", "S-Class", "G-Class"],
    "Suzuki": ["Swift", "Vitara", "S-Cross", "DL 650 V-Strom (Motor)"]
}

async def seed_vehicles():
    engine = create_async_engine(DATABASE_URL)
    try:
        async with engine.begin() as conn:
            print(f"--- Csatlakozás az adatbázishoz... ---")
            for make, models in INITIAL_DATA.items():
                await conn.execute(text("INSERT INTO ref.vehicle_makes (name) VALUES (:name) ON CONFLICT (name) DO NOTHING"), {"name": make})
                
                result = await conn.execute(text("SELECT id FROM ref.vehicle_makes WHERE name = :name"), {"name": make})
                make_id = result.scalar()
                
                for model in models:
                    category = "Motor" if "(Motor)" in model else "Autó"
                    clean_model = model.replace(" (Motor)", "")
                    await conn.execute(text("INSERT INTO ref.vehicle_models (make_id, model_name, category) VALUES (:make_id, :name, :cat) ON CONFLICT DO NOTHING"), {"make_id": make_id, "name": clean_model, "cat": category})
                    print(f"✅ Mentve: {make} -> {clean_model} ({category})")
        print("\n--- SIKER! Az adatbázis feltöltése befejeződött. ---")
    except Exception as e:
        print(f"\n❌ HIBA TÖRTÉNT: {e}")
    finally:
        await engine.dispose()

if __name__ == "__main__":
    asyncio.run(seed_vehicles())
EOF

