mysql mysqlpp_MySQL++简介

http://blog.csdn.net/whuqin/article/details/7757841

Mysql++是官方发布的、一个为MySQL设计的C++语言的API。Mysql++为Mysql的C-Api的再次封装,它用STL(Standard Template Language)开发并编写,并为C++开发者提供像操作STL容器一样方便的操作数据库的一套机制。其官方API介绍:MySQL++ Reference Manual

与JDBC一样,先建立连接Connection,创建Query,执行操作获得结果。

SimpleResult Query::store()进行更新、删除、创建等操作,SimpleResult代表执行状态,查询是否成功、影响了多少行。

StoreQueryResult Query::store():最常用。StoreQueryResult继承vector<:row>,Row类似于vector,表示一行中各列的数据。使用可以result[1][4]或result[2]["price"]。

UseQueryResult Query::use(),大结果查询,UserQueryResult是iterator,一次只能获得一个行结果,不停地next直到结束为止。

简单示例

#include 

// Connect to the sample database.

mysqlpp::Connection conn(false);

if(conn.connect(db, server, user, pass)) {

// Retrieve a subset of the sample stock table set up by resetdb

// and display it.

mysqlpp::Query query = conn.query("select item from stock");

if(mysqlpp::StoreQueryResult res = query.store()) {

cout <

for(size_ti = 0; i 

cout <

}

}

else{

cerr <

return1;

}

return0;

}

else{

cerr <

return1;

}

对查询结果的处理

#include 

#include 

lexical_cast ((mysqlpp::Null)field)

lexical_cast ((mysqlpp::Null)field)

lexical_cast ((mysqlpp::Null)field)

lexical_cast ((mysqlpp::Null)field)

lexical_cast<:string> ((mysqlpp::Null)field)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以帮你解答关于Ubuntu下Postfix +Dovecot邮件服务器搭建的问题。以下是大致的步骤: 1. 安装Postfix和Dovecot 在Ubuntu终端输入以下命令安装Postfix和Dovecot: ``` sudo apt-get update sudo apt-get install postfix dovecot-core dovecot-imapd dovecot-pop3d ``` 2. 配置Postfix 在终端中输入以下命令打开Postfix的主配置文件: ``` sudo nano /etc/postfix/main.cf ``` 在文件中搜索以下两行内容并进行修改: ``` myhostname = your_domain_name mydestination = your_domain_name, localhost.localdomain, localhost ``` 将“your_domain_name”替换为您的域名。 接下来,找到以下行并更改以允许邮件的发送和接收: ``` inet_interfaces = all ``` 最后,添加以下内容使Postfix能够与Dovecot一起工作: ``` home_mailbox = Maildir/ mailbox_command = ``` 保存并关闭文件。 3. 配置Dovecot 打开Dovecot的主配置文件: ``` sudo nano /etc/dovecot/dovecot.conf ``` 找到以下行并进行修改: ``` protocols = imap pop3 ``` 将其更改为: ``` protocols = imap pop3 lmtp ``` 然后,找到以下行并进行修改: ``` mail_location = mbox:~/mail:INBOX=/var/mail/%u ``` 将其更改为: ``` mail_location = maildir:~/Maildir ``` 保存并关闭文件。 4. 配置MySQL 如果您想要使用MySQL存储邮件,可以按照以下步骤进行配置: - 安装MySQL: ``` sudo apt-get install mysql-server ``` - 创建数据库和用户: ``` sudo mysql -u root -p ``` ``` CREATE DATABASE mailserver; CREATE USER 'mailuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON mailserver.* TO 'mailuser'@'localhost'; FLUSH PRIVILEGES; ``` - 创建表格: ``` sudo mysql -u mailuser -p mailserver < /etc/postfix/mysql_virtual_mailbox_domains.sql sudo mysql -u mailuser -p mailserver < /etc/postfix/mysql_virtual_mailbox_maps.sql sudo mysql -u mailuser -p mailserver < /etc/postfix/mysql_virtual_alias_maps.sql ``` 5. 重启服务 在终端中输入以下命令以重启Postfix和Dovecot: ``` sudo systemctl restart postfix sudo systemctl restart dovecot ``` 完成以上步骤后,您的Ubuntu邮件服务器将已经搭建完成。您可以测试是否正常工作,例如发送和接收一封电子邮件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值