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
    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    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.