Closed ClericPy closed 8 years ago
Not sure I understand -- terminate()
closes the connection and then attempts to delete the sqlite file.
What problem exactly are you reporting -- can you post the full log, at DEBUG level?
And also your OS, version of python, version of sqlitedict. Thanks!
Thanks for your answer & sorry for bother you... there is one python process is using that db and never be killed(maybe some sub-process), so it is not an issue any more. by the way, may I ask one more question, the file size didn't release after I used db.clear(), even it had nothing in.
Alright, closing this issue.
Regarding clear()
: it clears (deletes) all rows in a table, but doesn't VACUUM the space. Basically sqlite does some internal optimizations and gradually re-uses the now-empty space, rather than removing it.
I think that the vacuum operation was sometimes causing trouble we though was unnecessary, so we don't call it by default from clear()
.
If you need the space, feel free to call VACUUM manually. Or delete/terminate the entire DB file and start from scratch.
You really did me a big favor, and I learned much from here, thanks conn=sqlite3.connect('xx.sqlite') conn.execute("VACUUM") conn.execute("VACUUM") conn.execute("VACUUM") conn.close() makes good
No problem. Enjoy!
@ClericPy Thanks for the response. Is there any reason to execute the "VACUUM" three times. It seems one time does the work. Please let me know your thoughts.
.terminate() raise an error for it's in use when del the file, and after clear() the file size is still as large as before(43MB, not 3KB). Indeed I prefer sqlitedict to tinydb...