19 lines
536 B
Python
19 lines
536 B
Python
from fastapi import APIRouter, HTTPException
|
|
import MySQLdb
|
|
from ..database import get_db_connection
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/")
|
|
def read_skills():
|
|
conn = get_db_connection()
|
|
try:
|
|
with conn.cursor() as cursor:
|
|
sql = "SELECT * FROM skills;"
|
|
cursor.execute(sql)
|
|
result = cursor.fetchall()
|
|
return {"data": result}
|
|
except MySQLdb.Error as e:
|
|
raise HTTPException(status_code=500, detail=f"Erreur base de données: {e}")
|
|
finally:
|
|
conn.close() |