开心123 发表于 2018-10-4 10:30:02

mysql++使用实例

  #include
  #include
  #include
  #include
  using namespace std;
  const char * db_name= "mysql_cpp_data";
  const char * host   = "localhost";
  const char * username = "root";
  const char * password = "passwd";
  struct stock {
  int item;
  int num;
  float weight;
  int price;
  string sdate;
  };
  int main(int argc, char *argv[])
  {
  #if 1
  try {
  // Establish the connection to the database server.
  mysqlpp::Connection con(mysqlpp::use_exceptions);
  if (!con.connect(db_name, host, username, password)) {
  return 1;
  }
  mysqlpp::Query query = con.query();
  query
页: [1]
查看完整版本: mysql++使用实例