C ++程序与MySQL数据库通信 [英] C++ Program communicating with MySQL Database
问题描述
有人知道C ++程序直接与MySQL数据库通信的简单方法吗?我查看了MySQL ++,发现它非常令人困惑.如果有人知道执行此操作非常简单的方法,请告诉我.
Does anyone know of a simple way for a C++ program to communicate directly with a MySQL database? I have looked at MySQL++ and found it to be very confusing. If anyone knows of a very simple way of doing this, please let me know.
谢谢
P.S.我正在Windows机器上进行开发. PHP和MySQL Web Web应用程序设置. C ++安装程序可以与串行端口通信.因此,为什么我需要一种让C ++直接与MySQL数据库对话的方法.
P.S. I am developing on a Windows machine. PHP and MySQL web web application setup. C++ setup to talk to the serial port. Thus why I need a way for C++ to talk to the MySQL database directly.
推荐答案
There are quite a few database API wrappers but my favourite - and the one I recommend - is the SOCI library. Much nicer syntax than using the raw C API.
SOCI网站上的激励"示例:
The 'motivating' example from the SOCI website:
int id = ...;
string name;
int salary;
sql << "select name, salary from persons where id = " << id, into(name), into(salary);
这篇关于C ++程序与MySQL数据库通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!