Mercurial > libervia-backend
comparison src/memory/sqlite.py @ 936:6404df5305e3
memory: be sure that local_dir exists before creating a new database
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 25 Mar 2014 14:57:38 +0100 |
parents | 34dd9287dfe5 |
children | 301b342c697a |
comparison
equal
deleted
inserted
replaced
935:5b2d2f1f05d0 | 936:6404df5305e3 |
---|---|
80 self.initialized = defer.Deferred() # triggered when memory is fully initialised and ready | 80 self.initialized = defer.Deferred() # triggered when memory is fully initialised and ready |
81 self.profiles = {} # we keep cache for the profiles (key: profile name, value: profile id) | 81 self.profiles = {} # we keep cache for the profiles (key: profile name, value: profile id) |
82 | 82 |
83 info(_("Connecting database")) | 83 info(_("Connecting database")) |
84 new_base = not os.path.exists(db_filename) # do we have to create the database ? | 84 new_base = not os.path.exists(db_filename) # do we have to create the database ? |
85 if new_base: # the dir may not exist if it's not the XDG recommended one | |
86 dir_ = os.path.dirname(db_filename) | |
87 if not os.path.exists(dir_): | |
88 os.makedirs(dir_, 0700) | |
85 self.dbpool = adbapi.ConnectionPool("sqlite3", db_filename, check_same_thread=False) | 89 self.dbpool = adbapi.ConnectionPool("sqlite3", db_filename, check_same_thread=False) |
86 | 90 |
87 # init_defer is the initialisation deferred, initialisation is ok when all its callbacks have been done | 91 # init_defer is the initialisation deferred, initialisation is ok when all its callbacks have been done |
88 # XXX: foreign_keys activation doesn't seem to work, probably because of the multi-threading | 92 # XXX: foreign_keys activation doesn't seem to work, probably because of the multi-threading |
89 # All the requests that need to use this feature should be run with runInteraction instead, | 93 # All the requests that need to use this feature should be run with runInteraction instead, |