Results 1 to 14 of 14

Thread: Best method to insert data into 500 tables in SQLITE

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Best method to insert data into 500 tables in SQLITE

    I personally think that you should start with a good book about database design.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Best method to insert data into 500 tables in SQLITE

    You start the thread with:
    i need to create 500 different tables
    and then reinforce that with:
    i am in a fix on how to go about inserting data for 500 Channels into 500 different tables.
    Ultimately it seems that you want 500 columns in a single table:
    This is what i want to achieve. I am trying to create 500 Channels from Channel 1 to Channel 500 and Time Stamp in the first column, insert data into it every second i have all the channel data processed in a QVector<QString> i need to insert it into data dase. I read in the Detailed Description of QString, how do i overcome this problem cause i will have 500 columns but here i can use only upto 99 place markers.
    The obvious solution to the problem as stated is to build the row with a series of queries rather than one. You may also be able to make this work using parameterised queries and bind parameters in QSqlQuery (Sqlite limit seems to be 999 parameters by default).

    The far superior solution is to sit down and design the database properly as tbscope advises. Sqlite will allow more than 500 columns but that certainly does not make doing so a good idea. I think a table with three columns will do it and will even adapt easily to the arrival of a 501st channel.

  3. #3
    Join Date
    Dec 2010
    Posts
    41
    Thanks
    12

    Default Re: Best method to insert data into 500 tables in SQLITE

    Hello sir, thank you for your time.

    i am sorry that was a mistake. i meant 500 columns not tables.
    i am in a fix on how to go about inserting data for 500 Channels into 500 different tables.
    Qt Code:
    1. I think a table with three columns will do it and will even adapt easily to the arrival of a 501st channel
    To copy to clipboard, switch view to plain text mode 
    but i might have different data for each column for Channel , so i though i must have 500 columns to save each channels data. How could i use a table of only three columns to accommodate 500 different channels of data.?
    I did go through sqlite faq to find some answer but din't find any.

    thank you

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Best method to insert data into 500 tables in SQLITE

    I am with tbscope:
    Quote Originally Posted by tbscope View Post
    I personally think that you should start with a good book about database design.
    Although I suspect that even a rudimentary overview would suffice.

    Ponder this:
    Qt Code:
    1. CREATE TABLE channelData (
    2. sampletime integer,
    3. chNumber integer,
    4. chData varchar(250)
    5. );
    To copy to clipboard, switch view to plain text mode 
    Every sample:
    Qt Code:
    1. BEGIN TRANSACTION
    2. INSERT INTO channelData ( sampletime, chNumber, chData )
    3. VALUES (strftime('%s', 'now'), 0, "some ch0 data");
    4. INSERT INTO channelData ( sampletime, chNumber, chData )
    5. VALUES (strftime('%s', 'now'), 1, "some ch1 data");
    6. INSERT INTO channelData ( sampletime, chNumber, chData )
    7. VALUES (strftime('%s', 'now'), 2, "some ch2 data");
    8. ...
    9. INSERT INTO channelData ( sampletime, chNumber, chData )
    10. VALUES (strftime('%s', 'now'), 499, "some ch499 data");
    11. COMMIT;
    To copy to clipboard, switch view to plain text mode 
    and later this:
    Qt Code:
    1. SELECT * from channelData where chNumber = 2 order by sampletime;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Insert unicode in SQlite
    By Kastagne in forum Qt Programming
    Replies: 3
    Last Post: 11th October 2011, 14:07
  2. How to insert row to SQLite database?
    By MIH1406 in forum Qt Programming
    Replies: 6
    Last Post: 29th May 2010, 12:22
  3. Replies: 0
    Last Post: 21st April 2010, 16:25
  4. Way to load all of data from 2 tables into one QTableView?
    By Kevin Hoang in forum Qt Programming
    Replies: 8
    Last Post: 3rd April 2010, 09:42
  5. Bulk insert into SQLite
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2007, 03:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.