andri-ch / gotoword

vim plugin that gives users the possibility to write and access documentation about the word or expr. under cursor
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Should I keep database_operations decorator? #1

Closed andri-ch closed 9 years ago

andri-ch commented 9 years ago

This decorator opens & closes the connection to SQLite DB in order to minimize the chances of the file getting corrupted, and wraps most of the functions. There are situations when a lot of time passes between operations on DB.

How To Corrupt An SQLite Database File - https://www.sqlite.org/howtocorrupt.html

However, wrapped functions call other wrapped functions, inside functions return and call other wrapped functions, and, sometimes, a DB operation fails just because the database is closed by some wrapped functions.

What should I do?

  1. close only when the script exits
  2. open and close the db for every DB operation, not for every function that contains a connection to db.
andri-ch commented 9 years ago

after switching to django ORM, this issue is not relevant anymore.