35 lines
1.4 KiB
Python
Executable File
35 lines
1.4 KiB
Python
Executable File
import asyncio
|
|
from sqlalchemy import text
|
|
from app.db.session import engine
|
|
|
|
# Discovery adatok a 200 márkához (példa bővíthető)
|
|
MODELS_DISCOVERY = {
|
|
"Toyota": ["Corolla", "Yaris", "Hilux", "RAV4", "C-HR", "Avensis", "Land Cruiser"],
|
|
"Volkswagen": ["Golf", "Passat", "Polo", "Tiguan", "Touran", "Transporter", "Caddy"],
|
|
"BMW": ["3 Series", "5 Series", "X5", "X3", "1 Series", "7 Series"],
|
|
"Honda": ["Civic", "CR-V", "Jazz", "Accord", "CB 500", "Africa Twin"], # Autó és motor is!
|
|
"Yamaha": ["MT-07", "R1", "Tracer 900", "Ténéré 700", "XMAX"],
|
|
"Scania": ["R-series", "S-series", "G-series", "P-series"]
|
|
}
|
|
|
|
async def discovery_bot():
|
|
async with engine.begin() as conn:
|
|
print("🤖 Jármű típus felderítő bot indul...")
|
|
|
|
# Lekérjük az összes márkát
|
|
res = await conn.execute(text("SELECT id, name FROM data.vehicle_brands"))
|
|
brands = res.fetchall()
|
|
|
|
count = 0
|
|
for b_id, b_name in brands:
|
|
if b_name in MODELS_DISCOVERY:
|
|
for model in MODELS_DISCOVERY[b_name]:
|
|
await conn.execute(text(
|
|
"INSERT INTO data.vehicle_models (brand_id, name) VALUES (:b, :n) ON CONFLICT DO NOTHING"
|
|
), {"b": b_id, "n": model})
|
|
count += 1
|
|
|
|
print(f"✅ Bot végzett: {count} új típus rögzítve!")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(discovery_bot()) |