⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fieldinf1.cc

📁 有关MYSQL的开源码
💻 CC
字号:
#include <iostream>#include <iomanip>#include <mysqlcppapi/mysqlcppapi.h>int main() {  try { // its in one big try block    mysqlcppapi::Connection con;    con.connect();    con.select_database("mysql_cpp_data");    mysqlcppapi::Query query = con.create_Query();    query << "select * from stock" << std::ends;    mysqlcppapi::Result_Store res = query.store();        std::cout << "Query: " << query.preview() << std::endl;    std::cout << "Records Found: " << res.size() << std::endl << std::endl;    std::cout << "Query Info:\n";    std::cout.setf(std::ios::left);    const mysqlcppapi::Fields& fields = res.get_fields();    for (unsigned int i = 0; i < fields.size(); i++) {      const mysqlcppapi::FieldInfo& field = fields[i];      std::cout << std::setw(2)  << i	   << std::setw(15) << field.get_Name().c_str()	// this is the name of the field	   //<< setw(15) << field.get_FieldType().sql_name()	// this is the SQL identifier name	// Result::types(unsigned int) returns a mysql_type_info which in many	// ways is like type_info except that it has additional sql type	// information in it. (with one of the methods being sql_name())	   //<< setw(20) << field.get_FieldType().get_Name()	// this is the C++ identifier name which most closely resembles	// the sql name (its is implementation defined and often not very readable)	   << std::endl;    }    std::cout << std::endl;         return 0;  } catch (mysqlcppapi::ex_BadQuery& er) {      std::cerr << "Error: " << er.what() << std::endl;    return -1;  } catch (mysqlcppapi::ex_BadConversion& er) { // handle bad conversions      std::cerr << "Error: Tried to convert \"" << er.get_Data() << "\" to a \"" 	 << er.get_TypeName() << "\"." << std::endl;    return -1;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -