C++ Program communicating with MySQL Database

前端 未结 8 1460
醉梦人生
醉梦人生 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);
    
    0 讨论(0)
  • 2021-01-03 11:04

    The C MySQL API is just like using the PHP MySQL extension and so should be pretty familiar. If you are comfortable with C, I'd recommend that (and you don't mind mixing C in your C++).

    0 讨论(0)
提交回复
热议问题