int main()
{
MYSQL *mysql_con = conn::Connect();//连接
if (mysql_con == nullptr) {
printf("read_gantry_file sql connect error");
system("pause");
}
char * query0 = "set names utf8";
mysql_query(mysql_con, query0);//设置编码格式
string char_sql="select * from t_alg_veh_0 where str_license=\'云AH0590\' AND str_color=\'1\' AND time_t between "+to_string(1604231511-20)+" AND "+to_string(1604231511+20)+";" ;
char* query1 = new char[char_sql.size() + 1];
strcpy(query1,char_sql.c_str());
cout<<query1<<endl;
int sql_ret=mysql_query(mysql_con,query1);
if(sql_ret!=0)
{
cout<<"sql_error:"<<endl;
return 0;
}
MYSQL_RES *result=mysql_store_result(mysql_con);
if (result==NULL)
{
cout<<"sql_NULL"<<endl;
}
else
{
MYSQL_ROW row;
while (row=mysql_fetch_row(result))
{
unsigned long *col=mysql_fetch_lengths(result);
for (int i=0;i<mysql_num_fields(result);i++)
{
string out=row[i];
cout<<out<<";";
}
cout<<endl;
}
}
}