Results 1 to 11 of 11

Thread: new issue with sqlite archive event fucntion copies data from one db to another

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: new issue with sqlite archive event fucntion copies data from one db to another

    Please see this reply to your other post on the same subject and avoid starting new threads when you already have active threads on the same topic.

    I have no idea why you want to make this so hard either. In a prior post, I showed you how to attach a database to an existing SQLITE connection (your requirement was that the archive is in a separate database file) and then perform the archive by simply doing something like:

    Qt Code:
    1. attach database '/path/to/archive/db.sqlite' as arch;
    2. insert into arch.userlogevent select * from main.userlogevent where dateTime < datetime('now','localtime','-30 days');
    3. delete from main.userlogevent where dateTime < datetime('now','localtime','-30 days');
    To copy to clipboard, switch view to plain text mode 

    Needless to say, you should check success/failure of each SQL statement above before executing the next, i.e. you don't want to delete the records from the primary table if there were not inserted into the archive successfully, etc.

    All done in SQL, no loops required, no QDateTime comparisons needed at all.
    Last edited by jefftee; 7th October 2016 at 00:49.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  2. The following user says thank you to jefftee for this useful post:

    jfinn88 (7th October 2016)

Similar Threads

  1. Replies: 8
    Last Post: 7th October 2016, 19:14
  2. SQLite reading Chinese strings issue
    By yazwas in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2011, 08:37
  3. Protecting SQLite Data
    By zim in forum Newbie
    Replies: 23
    Last Post: 25th March 2011, 23:50
  4. QDevelop SQLite Driver Issue
    By Phan Sin Tian in forum Qt-based Software
    Replies: 4
    Last Post: 1st August 2010, 11:47
  5. data not being retained in sqlite DB
    By sticcino in forum Qt Programming
    Replies: 2
    Last Post: 2nd July 2008, 10:42

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.