0

I have seen multiple similar questions but none using python that I managed to make use of so I'm making a new post.

I'm trying to make a copy of a data base onto another one to create a history of it. And then repeat this process avery few minutes or so. but i can't seem to make the copy part work.

somthing similar to that process if it makes any sense i've seen commands like SELECT * insert history.db FROM updated.db; but it doesn't work. thanks for your time!

Vaibhav Jadhav
  • 2,020
  • 1
  • 7
  • 20
hey
  • 118
  • 9
  • Is mandatory using SQL queries like INSERT or you can lock the database and then copy it. Check: https://sqlite.org/backup.html https://stackoverflow.com/q/8045602/930271 https://stackoverflow.com/q/71150811/930271 – Francisco Puga Apr 02 '22 at 14:37
  • Please provide enough code so others can better understand or reproduce the problem. – Community Apr 02 '22 at 14:42
  • thanks i'll try to understand what you sent :) – hey Apr 02 '22 at 15:37

1 Answers1

2

Outside of SQLite, if not using the database (i.e. the connection is closed) then you can simply copy the file to a suitable file name (noting that if WAL is active and the file with the -wal suffix is not empty, then this and the file with the -tmp should also be copied, as they are part of the database).

If from within SQLite, you can use the VACUMM INTO the_file_name see https://www.sqlite.org/lang_vacuum.html

MikeT
  • 51,415
  • 16
  • 49
  • 68