admin 管理员组

文章数量: 887032


2024年1月17日发(作者:scrapy如何使用)

unsigned long client_flag = 0; /*A MYSQL* connection handler if the connection was successful, NULL if the connection was unsuccessful. For a successful connection, the return value is the same as the value of the first parameter.*/ if (mysql_real_connect(&m_mysql, host, user, passwd, db, port, unix_socket, client_flag)) { printf("The connection was successful.n"); return true; } else { printf("Error connecting to database:%sn", mysql_error(&m_mysql)); return false; }}void DBHandle::FreeMysqlConnect(){ mysql_free_result(res); mysql_close(&m_mysql);}bool DBHandle::insertDataToMysql(string strData){ char szQuery[256] = {0}; sprintf_s(szQuery, "insert into a_test (type) values ('%s');", strData.c_str()); if (mysql_query(&m_mysql, szQuery)) { printf("Query failed (%s)n", mysql_error(&m_mysql)); return false; } else { printf("Insert successn"); return true; }}   测试结果:

  2.写redis->写mysql,读Redis->未找到->读Mysql


本文标签: 使用 结果 作者