C++ Program communicating with MySQL Database

前端 未结 8 1475
醉梦人生
醉梦人生 2021-01-03 10:01

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 kno

8条回答
  •  攒了一身酷
    2021-01-03 10:58

    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.

    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);
    

提交回复
热议问题