poco mysql 库_Poco Mysql使用

连接时用到的一些字段, POCO官方文档中也有说明

\Data\MySQL\src\SessionImpl.cpp:69

options["host"]= "localhost";

options["port"]= "3306";

options["user"]= "";

options["password"]= "";

options["db"]= "";

options["compress"]= "";

options["auto-reconnect"]= "";

//连接

std::string mysql_poco::_dbConnString = "host=xxx.17.xx.68;user=xxx;password=xxx;db=bizcnvhost;compress=true;auto-reconnect=true";

Connector::registerConnector();

_pSession =  newSession(SessionFactory::instance().create(Connector::KEY,_dbConnString));

//增:

string s1 ="a1";

string s2 ="b2";

string s3 ="b3";

string s4 ="b4";

*_pSession<

//查

int count = 0;

*_pSession <

注意: use和into的用法, use用于添加数据into用于返回值

这好像似乎没什么,C接口同样可以实现,它的强处在下面:

1操作自定义结构体,例如插入一个自定义的结构体,或将返回的数据放到自定义的结构体中,

1定义你结构体,但必须重载()操作符

2特化模版类TypeHandler,并重写bindsizeextractprepare这4个静态函数,原型在poco-1.4.2p1-all\Data\include\Poco\Data\TypeHandler.h中

2操作元组

3操作map

4操作set

5操作vector

具体请参考: Poco提供的示例

Mysql 官方提供的c++库貌似有内存泄漏, 在windows 下没有,Linux 貌似就有

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值