Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as Mysql from "mysql";
- import { Localconfig } from "../environment/localconfig";
- export class Database {
- private static pool = Mysql.createPool({
- connectionLimit: 20,
- host: Localconfig.mysql.host,
- user: Localconfig.mysql.user,
- password: Localconfig.mysql.password,
- database: Localconfig.mysql.database
- });
- public static exec(query: string, params: any[], callback: Function) {
- return this.pool.getConnection((err, connection) => {
- if (err) {
- if (connection) connection.release();
- throw err;
- }
- connection.query(query, params, (err, res) => {
- connection.release();
- if (!err) {
- callback(res);
- }
- });
- connection.on("error", err => {
- throw err;
- });
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement