Version 1.0.1.2 connection.release() in folder talas_v5_DB in all files

This commit is contained in:
ISA
2024-09-05 09:59:49 +02:00
parent 34449e3710
commit 2623da410e
3 changed files with 12 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
// /pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js
import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren
export default async function handler(req, res) {

View File

@@ -1,4 +1,4 @@
// pages/api/addLocation.js
// pages/api/talas_v5_DB/pois/addLocation.js
import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren
export default async function handler(req, res) {

View File

@@ -6,16 +6,23 @@ import getPool from "../../../utils/mysqlPool"; // Singleton-Pool importieren
export default async function handler(req, res) {
const pool = getPool(); // Singleton-Pool verwenden
let connection;
try {
// Verbindung abrufen
connection = await pool.getConnection();
// Ausführen der Datenbankabfrage
const query = "SELECT idprio, level, name, color FROM prio";
const [results] = await pool.query(query);
const [results] = await connection.query(query);
// Wichtig: Senden Sie die Antwort zurück
res.status(200).json(results); // Nur rows werden zurückgegeben
// Senden Sie die Antwort zurück
res.status(200).json(results);
} catch (error) {
console.error("Fehler beim Abrufen der API", error);
res.status(500).json({ error: "Fehler bei der Abfrage" });
} finally {
// Verbindung freigeben
if (connection) connection.release();
}
}