Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Database table transfer over TCP
Forum Updated to NodeBB v4.3 + New Features

Database table transfer over TCP

Scheduled Pinned Locked Moved Unsolved General and Desktop
databasedata transfertcpsocketqt 5.7.0
21 Posts 4 Posters 11.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D DoughBoy
    26 Sept 2016, 15:56

    Hello everyone!
    I've tried to implement both methods, but I've ran into a slight snag.

    @kshegunov
    Your method is straight forward! With a QDataStream writing to a QByteArray, I first store the column headers (as QString) and all data values (as QVarient). Then to a parenting QByteArray I keep track of the Database name, Table name, number of rows, number of columns, and the data collection's QByteArray. It is then this parenting QByteArray I send to the remote platform for data extraction and storage. Working with 20 days of data, I was able to collect, transmit, and store the data in just about 4 minutes (not that this matters, but it's a way for me to compare the performance difference).

    @mjsurette
    I'm having a difficult time getting your strategy implemented. I'm able to populate a QSqlTableModel with my desired SQL query. I'm using the TableModel because it is said that this object can easily read/write to a database table. Sadly though, how do I then take the table's data and switch to a new QSqlDatabase object (this is defined in the QSqlTableModel's constructor)? The way we discussed this, I would have 2 different QSqlDatabase objects - 1) is the original data; 2) is the exported data. Could you offer some more guidance with how I can move data from one database to another?

    Thanks and I look forward to hearing from you.

    M Offline
    M Offline
    mjsurette
    wrote on 26 Sept 2016, 23:31 last edited by
    #21

    @DoughBoy
    The following SQL, with the Chinook test database open will create a new file in the same directory named 'out.sqlite' holding all of the album information for artist 51 with the original table layout.

    A Qt model is totally unnecessary. Just run the query and it will create your file. From there you can compress it and ship it.

    ATTACH DATABASE 'out.sqlite' AS outdb;
    
    CREATE TABLE  outdb.album
    AS
    SELECT * from album
    WHERE ArtistId = 51;
    
    DETACH DATABASE outdb;
    

    It does use SQLite specific sql.

    Note especially that the ATTACH DATABASE and DETACH DATABASE are sql to be sent to the database just like the CREATE TABLE..

    BTW, I have never done this using Qt, only in batch files, but I see no reason for it not to work both ways.

    Mike

    1 Reply Last reply
    0

    21/21

    26 Sept 2016, 23:31

    • Login

    • Login or register to search.
    21 out of 21
    • First post
      21/21
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved