Код: Выделить всё
#include
#include
#include
#include
#include "mysql/mysql.h"
const char* user = "root";
const char* passwd = "password";
const char* host = "127.0.0.1";
const char* db; // = "data";
int port = 3306;
MYSQL* connection = NULL, conn;
int main()
{
mysql_init(&conn);
connection = mysql_real_connect(&conn, host, user, passwd, NULL, port, NULL, CLIENT_MULTI_STATEMENTS);
auto resDB = mysql_select_db(&conn, "2024_04");
int odr1 = 0;
int odr2 = 1;
std::string str_concat = "";
while (true) {
std::string str_queryInsert1 = std::format("INSERT INTO tb (odr1, odr2) values( {}, {})", odr1, odr1);
std::string str_queryInsert2 = std::format("INSERT INTO tb (odr1, odr2) values( {}, {})", odr2, odr2);
str_concat.append(str_queryInsert1);
str_concat.append(";");
str_concat.append(str_queryInsert2);
str_concat.append(";");
odr1 += 1;
odr2 += 1;
if ((odr1 % 4) == 0) {
auto res = mysql_query(&conn, str_concat.c_str());
//auto res = mysql_query(&conn, str_queryInsert1.c_str());
Sleep(1000);
str_concat = "";
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78334078/multi-statements-sql-and-c[/url]