Return of the Database



  • What is the data format that the database returns to Qt?

    For example, I ran a SELECT query in the database, it returns in what format?

    You can send this return (format) per socket?

    Example, if return an object, that object can send per socket for a client application (socket)?



  • You need to read the documentation for the qtsql module:
    http://qt-project.org/doc/qt-4.8/qtsql.html



  • [quote author="l3e0wulf" date="1352375282"]What is the data format that the database returns to Qt?

    For example, I ran a SELECT query in the database, it returns in what format?[/quote]

    AFAIK, QVariant.This is what I use after I query from an SQL Database to retrieve the data - "QSqlQuery::value":http://qt-project.org/doc/qt-4.8/qsqlquery.html#value

    [quote author="l3e0wulf" date="1352375282"]You can send this return (format) per socket?

    Example, if return an object, that object can send per socket for a client application (socket)?[/quote]

    Sorry, I can't understand these questions. Can you make it clearer? Provide examples if possible. Thanks



  • QSQlQuery returns the QVariant as wrote Code ReaQtor. Maybe you can write your own Class which stores data from table and make it serializable. For example:
    @class TableData
    {
    QString TableName;
    QStringList ColumnNames;
    QList< QList<QVariant> > TableContent;
    }
    QDataStream &operator <<(QDataStream &out,const TableData &);
    QDataStream &operator >>(QDataStream &in, TableData &);
    @

    in ***.cpp file
    @
    QDataStream &operator <<(QDataStream &out,const TableData &tb_data)
    {
    out << tb_data.TableName << tb_data.ColumnNames << tb_data.TableContent;
    return out;
    }
    QDataStream &operator >>(QDataStream &in, TableData &tb_data)
    {
    tb_data = TableData();
    in >> tb_data.TableName >> tb_data.ColumnNames>> tb_data.TableContent;
    return in;
    }
    @

    You can serialize table in QByteArray (up to 2Gb) then transfer via Sockets.



  • Thank you.
    I'll be trying soon reply to you what happened.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.