• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript mysql.createPool函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中mysql.createPool函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createPool函数的具体用法?TypeScript createPool怎么用?TypeScript createPool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了createPool函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: connect

	// Executes a database statement on a pooled connection. All commands executed
	// on the connection are not guaranteed to run instantly, but are guaranteed to run
	// sequentially and serially.
	public connect(callback: ICallback) {
		if (!this._pool) {
			this._pool = mysql.createPool({
				connectionLimit: 10,
				host: this._config.mysqlHost,
				user: this._config.mysqlUser,
				password: this._config.mysqlPassword,
				database: this._config.mysqlDatabase,
				multipleStatements: true
			});
		}

		this._pool.getConnection((err: any, connection: any) => {
			if (err) {
				callback(err);
			} else {
				if (!this._checkedExists) {
					this.dbInit(connection, (err: any) => {
						if (err)
							return callback(err);
						else {
							this._checkedExists = true;
							return callback(null, connection);
						}
					});
				} else
					return callback(null, connection);
			}
		});
	}
开发者ID:kayateia,项目名称:flowerbox-server,代码行数:33,代码来源:MySQL.ts


示例2: createDbPool

 export function createDbPool() {
   return createPool({
     host: "localhost",
     user: "game",
     password: "asdf",
     database: "test",
     connectionLimit: 10
   });
 }
开发者ID:tbergqvist,项目名称:moist-silica,代码行数:9,代码来源:database.ts


示例3: constructor

	constructor(connectionConfig: DatabaseConnectionConfig, cacheEngine: CacheEngineInterface, notifier?: Notifier) {
		super(cacheEngine, notifier);

		// Lets create the connection pool
		this.pool  = mysql.createPool({
		  connectionLimit : connectionConfig.connectionPoolLimit,
		  host: connectionConfig.host,
		  user: connectionConfig.username,
		  password: connectionConfig.password,
		  database: connectionConfig.database
		});
	}
开发者ID:fabianTMC,项目名称:smart-query-cache,代码行数:12,代码来源:mysql.ts


示例4: createPool

 protected static createPool(cfg, name):mysql.IPool {
     let pool = mysql.createPool({
         connectionLimit: cfg.connectionLimit,
         host: cfg.host,
         database: cfg.database,
         user: cfg.user,
         password: cfg.password,
         dateStrings: true
     });
     winston.info("database(" + name + ") at:" + cfg.host + " pool created.");
     return pool;
 }
开发者ID:xiabin1235910,项目名称:example-typescript-decorator,代码行数:12,代码来源:baseDB.ts


示例5: connect

    connect(profile:DatabaseProfile) {

        this.profile = profile;

        logger.info(`Creando el pool de base de datos: ${this.profile.host}/${this.profile.database}`);
        try {
            this.connectionPool = createPool(this.profile);
        }
        catch(e) {
            logger.error(`Error al conectar con la base de datos: ${this.profile.host}/${this.profile.database}`
                ,e);
            process.exit(1);
        }
    }
开发者ID:antoniohueso,项目名称:sauron2.0,代码行数:14,代码来源:util.ts


示例6: init

 export function init() : void
 {
     db = Mysql.createPool(
     {
         host: process.env.SQL_HOST,
         user: process.env.SQL_USER,
         password: process.env.SQL_PASSWORD,
         database: process.env.SQL_DB,
         connectionLimit : 20
     });
     db.on("error", function(err: any)
     {
         Logging.trace(err);
     });
 }
开发者ID:p0ody,项目名称:ff2ebook-node,代码行数:15,代码来源:DBHandler.ts


示例7: constructor

    constructor(config: IConfig) {
        super();

        if (config.customFormat) {
            config.connection.queryFormat = this.customFormat;
        }

        this.config = config;

        this.pool = mysql.createPool(config.connection);

        if (config.verbose) {
            console.log(`Initialize ${config.name} connection`);
        }
    }
开发者ID:vruden,项目名称:node-mysql-connection,代码行数:15,代码来源:connection.ts


示例8: query

import * as mysql from 'mysql';



// 创建连接池:最大10个连接
export var pool = mysql.createPool({
    connectionLimit: 10,
    host: 'localhost',
    user: 'root',
    password: '1234',
    database: 'test'
});

/** 不允许直接使用连接池,而是通过该方法执行sql */
export function query(sql: string, params?: Object | any[]) {
    return new Promise((resolve, reject) => {
        pool.query(sql, params ? params : [], (err, rows, fields) => {
            if (err) reject(err);
            else resolve(rows);
        });
    });
}


// export async function query(sql: string, params?: any) {
//     return new Promise((resolve, reject) => {
//         pool.getConnection((err, connection) => {
//             connection.query(sql, params ? params : [], (err, rows) => {
//                 if (err) reject(err);
//                 else resolve(rows);
//                 connection.release();
开发者ID:gujiajia,项目名称:node.js,代码行数:31,代码来源:db.ts


示例9: constructor

    constructor(dbms: 'mysql' | 'postgresql', connection: mysql.IConnectionConfig, tableName: string) {
        this.dbms = dbms;
        this.tableName = tableName;

        this.pool = mysql.createPool(connection);
    }
开发者ID:vruden,项目名称:node-migrate,代码行数:6,代码来源:db-helper.ts


示例10: require

var mysql = require('mysql');

var pool = mysql.createPool({
    connectionLimit: 100, // important
    host: "localhost",
    user: "root",
    password: "123",
    database: "koodkaco",
    debug: false
});

export function handle_database(query, callBack) {

    pool.getConnection(function (err, connection) {

        if (err) {
            console.log(err);
            connection.release();
            callBack({ error: true, msg: "Error in connection database: " + err });
            // res.json({ "code": 100, "status": "Error in connection database" });
            // return;
        }

        console.log('connected as id ' + connection.threadId);

        connection.query(query, function (err, rows) {
            connection.release();
            if (!err) {
                callBack({ error: false, data: rows });
                // res.json(rows);
            }
开发者ID:uqutub,项目名称:NodejsMySql,代码行数:31,代码来源:mysql.ts



注:本文中的mysql.createPool函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript mysql.escape函数代码示例发布时间:2022-05-25
下一篇:
TypeScript mysql.createConnection函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap