C语言数据库连接池 libzdb

Libzdb 实现了一个小型、快速和易用的线程安全的连接池数据库API,可连接多种数据库,零配置,通过URL指定连接信息。

Example: 默认建立5个连接

  URL_T url = URL_new("mysql://localhost/test?user=root&password=swordfish");
 ConnectionPool_T pool = ConnectionPool_new(url);
 ConnectionPool_start(pool);
 [..]
 Connection_T con = ConnectionPool_getConnection(pool);
 ResultSet_T result = Connection_executeQuery(con, "select id, name, image from employee where salary>%d", anumber);
 while (ResultSet_next(result)) 
 {
      int id = ResultSet_getInt(result, 1);
      const char *name = ResultSet_getString(result, 2);
      int blobSize;
      const void *image = ResultSet_getBlob(result, 3, &blobSize);
      [..]
 }
 Connection_close(con);
 [..]
 ConnectionPool_free(&pool);
 URL_free(&url);
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值