I'd use mysqls prepared statement API to do this.
You can see a complete example here.
You'd just loop over the vector rebinding to the new values and reexecuting the statement. This will probably be more efficient and less error prone (harder to suffer from SQL injection type attacks) than manually constructing and rerunning the query.
The other option (Not as good IMO, but simpler and can suffer from sql injection issues if you're not careful) is to loop over the vector constructing the query in a stringstream and then using the stringstream buffer.
The string stream method looks a bit like this (untested and probably buggy):
vector<pair<string,int> > values = get_my_values();
stringstream query;
query<<"insert into test values";
for( vector<pair<string,int> >::iterator it = values.begin() ;
it != values.end();
++it )
{
query<<"(\""<<mysql_real_escape(connection, it->first.c_str())<<"\","<<it->second<<")";
if( it+1 != values.end() ) { query<<","; }
}
query_state=mysql_query(connection, query.str().c_str() );
{}button.