diff options
author | florent <florent@toopy.org> | 2012-01-19 01:05:56 (GMT) |
---|---|---|
committer | florent <florent@toopy.org> | 2012-01-19 01:05:56 (GMT) |
commit | acb4b6642e50c901bd498daa5bd48bd910550457 (patch) | |
tree | 55c3978616bd27fd2079d00600f329e3a8e65b90 | |
parent | 706653955214c2a80892995a4755178eb40986e3 (diff) |
ensure good start
-rw-r--r-- | atoidejouer/db/story.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/atoidejouer/db/story.py b/atoidejouer/db/story.py index 426baa1..6496bff 100644 --- a/atoidejouer/db/story.py +++ b/atoidejouer/db/story.py @@ -1,5 +1,5 @@ # python import -import copy, logging +import copy, logging, os # get application logger logger = logging.getLogger('atoidejouer') @@ -278,12 +278,17 @@ class DB(object): def __init__(self, create=False, name="story", obj=Key): self.name, self.obj = name, obj db_path = storage.get_db_path('default') - self.con = sqlite3.connect(db_path, - detect_types=sqlite3.PARSE_DECLTYPES, - check_same_thread=False) - self.con.row_factory = sqlite3.Row - if create is True: - self.__create() + # DEBUG + logger.debug('[db.story] init - db_path: %s' % db_path) + if os.path.exists(os.path.dirname(db_path)): + # DEBUG + logger.debug('[db.story] init - dirname found!') + self.con = sqlite3.connect(db_path, + detect_types=sqlite3.PARSE_DECLTYPES, + check_same_thread=False) + self.con.row_factory = sqlite3.Row + if create is True: + self.__create() def __create(self): cur = self.con.cursor() @@ -323,7 +328,6 @@ class DB(object): cur = self.con.cursor() # DEBUG # logger.debug('[db.story] get - query: %s' % obj.select()) - # DEBUG cur.execute(obj.select()) for obj in self._fetch(cur): yield obj |