Commit existing log file in SQLite from previous completed database connection

I am creating a prototype script that creates large SQLite databases with a four-day limit. The time limit has been reached before the script is completed, and the connection.commit () command will be executed. the script is discarded and the connection to the database ends, but the log is still in the file directory where the database was created.

I want to commit an existing log to see if the current script is on the right path. Initially, I just try (using the Python sqlite3 module on iPython):

connection = sqlite3.connect('mydatabase') connection.commit() 

but I suspect that I need to indicate that I want to commit an existing log. I tried passing the log name as an argument to commit (), but commit () does not accept arguments in the python sqlite3 module.

In the future I will gradually increase .commit ()

+4
source share
1 answer

When SQLite changes the database, some new data is stored in the SQLite cache, other new data will be written to disk. When SQLite is killed in the middle of a transaction, all data in the cache is lost, so the state of the database will be inconsistent. In this situation, the only option is to roll back the transaction to return to a consistent state.

The -journal file actually contains the old data, the new data was written to the actual DB file. If you really want to see the changes made by your partial transaction, you can try to delete the -journal file (which does not allow SQLite to perform automatic return) and then open the database, but the database state is then incompatible, so you probably wonโ€™t be able to get access to all data.

+3
source

Source: https://habr.com/ru/post/1444449/


All Articles