Initial commit: Robot ökoszisztéma v2.0 - Stabilizált jármű és szerviz robotok
This commit is contained in:
32
backend/seed_discovery.py
Executable file
32
backend/seed_discovery.py
Executable file
@@ -0,0 +1,32 @@
|
||||
import asyncio
|
||||
import httpx
|
||||
from sqlalchemy import text
|
||||
from app.db.session import SessionLocal
|
||||
|
||||
async def seed():
|
||||
print("🚀 RDW Márka-felfedezés indul...")
|
||||
url = "https://opendata.rdw.nl/resource/m9d7-ebf2.json?$select=distinct%20merk&$limit=50000"
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
resp = await client.get(url, timeout=60)
|
||||
if resp.status_code != 200:
|
||||
print(f"❌ Hiba: {resp.status_code}")
|
||||
return
|
||||
|
||||
makes = resp.json()
|
||||
print(f"📦 {len(makes)} márkát találtam. Mentés...")
|
||||
|
||||
async with SessionLocal() as db:
|
||||
for item in makes:
|
||||
m = item['merk'].upper()
|
||||
# ON CONFLICT: Ha már benne van (pl. n8n betette), ne legyen hiba
|
||||
await db.execute(text("""
|
||||
INSERT INTO data.catalog_discovery (make, model, source, status)
|
||||
VALUES (:m, 'ALL', 'global_seed', 'pending')
|
||||
ON CONFLICT DO NOTHING
|
||||
"""), {"m": m})
|
||||
await db.commit()
|
||||
print("✅ Kész! A discovery tábla felöltve az összes EU-s márkával.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(seed())
|
||||
Reference in New Issue
Block a user