如何在连接器C++中将原始字节转换为字符串 >我使用连接器C++来通过C++对MySQL进行查询,除日期类型外,一切都正常!p>

如何在连接器C++中将原始字节转换为字符串 >我使用连接器C++来通过C++对MySQL进行查询,除日期类型外,一切都正常!p>,c++,mysql,sql,datetime,C++,Mysql,Sql,Datetime,当我试图打印查询产生的数据时,除了日期类型的列之外,所有列都会打印,而不是打印它们打印的日期值 如何以日期yyy-mm-dd的真实形式打印,而不是 这是我的代码: #include <iostream> #include <mysqlx/xdevapi.h> using namespace std; using namespace mysqlx; template<typename type> void print(const list<type&g

当我试图打印查询产生的数据时,除了日期类型的列之外,所有列都会打印,而不是打印它们打印的日期值

如何以日期yyy-mm-dd的真实形式打印,而不是

这是我的代码:

#include <iostream>
#include <mysqlx/xdevapi.h>

using namespace std;
using namespace mysqlx;

template<typename type>
void print(const list<type>& lst) noexcept
{
    for (auto it{ lst.begin() }; it != lst.end(); it++)
    {
        try
        {
            int index{ 0 };
            while (true)
                cout << (*it)[index++] << '\t';
        }
        catch (...)
        {
            cout << endl;
        }
    }
}

int main(int argc, char** argv, char** pnv)
{
    Session dbms_session{
        SessionOption::HOST, "localhost",
        SessionOption::PORT, 33060,
        SessionOption::USER, "myusername",
        SessionOption::PWD, "mypassword",
        SessionOption::DB, "classicmodels",
        SessionOption::SSL_MODE, SSLMode::DISABLED
    };
    Schema classicmodels_schema{ dbms_session.getSchema("classicmodels") };

    Table employees_table{ classicmodels_schema.getTable("employees") };
    RowResult employees_full_name{ employees_table.select("firstName", "lastName").execute() };

    list<Row> employees_full_name_result{ employees_full_name.fetchAll() };

    Table members_table{ classicmodels_schema.getTable("members") };
    Table committees_table{ classicmodels_schema.getTable("committees") };

    const char* sql_command{
        "SELECT\n"
        "customers.customerNumber,\n"
        "customers.contactLastName,\n"
        "customers.contactFirstName,\n"
        "orders.orderDate,\n"
        "orders.status\n"
        "FROM customers\n"
        "INNER JOIN orders\n"
        "USING (customerNumber);\n"
    };

    RowResult databases{ dbms_session.sql(sql_command).execute() };

    list<Row> data{ databases.fetchAll() };
    print(data);
}
这是我的结果:

363     Young   Dorothy <3 raw bytes>   Shipped
128     Keitel  Roland  <3 raw bytes>   Shipped
181     Frick   Michael <3 raw bytes>   Shipped
121     Bergulfsen      Jonas   <3 raw bytes>   Shipped
141     Freyre  Diego   <3 raw bytes>   Shipped
145     Petersen        Jytte   <3 raw bytes>   Shipped
278     Rovelli Giovanni        <3 raw bytes>   Shipped
131     Lee     Kwai    <3 raw bytes>   Shipped
385     Cruz    Arnold  <3 raw bytes>   Shipped
486     Salazar Rosa    <3 raw bytes>   Shipped
187     Ashworth        Rachel  <3 raw bytes>   Shipped
129     Murphy  Julie   <3 raw bytes>   Shipped
144     Berglund        Christina       <3 raw bytes>   Shipped
124     Nelson  Susan   <3 raw bytes>   Shipped
172     Bertrand        Marie   <3 raw bytes>   Shipped
424     Hernandez       Maria   <3 raw bytes>   Shipped

示例结果很好,但不是太多。我不喜欢这样一个事实,即这些可能是真实的订单,您在这里提供了很多合理的数据:不,这是一个示例数据库classicmodels,我仅用于编程和测试。没有合理的数据。。。
use below command 
select date_format(<column name with type>,'%Y-%m-%d') from <table name>;