mysql createPool

This commit is contained in:
ISA
2024-09-02 09:06:49 +02:00
parent ac80c8c619
commit ea46bd771b
52 changed files with 2026 additions and 437 deletions

View File

@@ -1,27 +1,9 @@
// /pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js
import mysql from "mysql2";
// Erstellen eines Pools von Datenbankverbindungen
const pool = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
port: process.env.DB_PORT,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
});
pool.on("connection", function (connection) {
console.log("Database connected successfully.");
});
pool.on("error", function (err) {
console.error("Fehler beim Verbinden:", err);
});
import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren
export default function handler(req, res) {
const pool = getPool(); // Singleton-Pool verwenden
const idMap = req.query.idMap;
if (req.method !== "GET") {
return res.status(405).json({ error: "Nur GET Methode erlaubt" });