mysql createPool
This commit is contained in:
@@ -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" });
|
||||
|
||||
Reference in New Issue
Block a user