OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """SQLite-based storage.""" | 2 """SQLite-based storage.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import sqlite3 | 8 import sqlite3 |
9 import zlib | 9 import zlib |
10 | 10 |
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 if not path: | 920 if not path: |
921 raise ValueError('Missing path.') | 921 raise ValueError('Missing path.') |
922 | 922 |
923 path = os.path.abspath(path) | 923 path = os.path.abspath(path) |
924 | 924 |
925 connection = sqlite3.connect( | 925 connection = sqlite3.connect( |
926 path, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) | 926 path, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) |
927 | 927 |
928 cursor = connection.cursor() | 928 cursor = connection.cursor() |
929 if not cursor: | 929 if not cursor: |
930 return False | 930 return |
931 | 931 |
932 self._connection = connection | 932 self._connection = connection |
933 self._cursor = cursor | 933 self._cursor = cursor |
934 self._is_open = True | 934 self._is_open = True |
935 self._read_only = read_only | 935 self._read_only = read_only |
936 | 936 |
937 if read_only: | 937 if read_only: |
938 self._ReadStorageMetadata() | 938 self._ReadStorageMetadata() |
939 else: | 939 else: |
940 # self._cursor.execute('PRAGMA journal_mode=MEMORY') | 940 # self._cursor.execute('PRAGMA journal_mode=MEMORY') |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1057 |
1058 Args: | 1058 Args: |
1059 task_start (TaskStart): task start information. | 1059 task_start (TaskStart): task start information. |
1060 | 1060 |
1061 Raises: | 1061 Raises: |
1062 IOError: when the storage file is closed or read-only. | 1062 IOError: when the storage file is closed or read-only. |
1063 """ | 1063 """ |
1064 self._RaiseIfNotWritable() | 1064 self._RaiseIfNotWritable() |
1065 | 1065 |
1066 self._WriteAttributeContainer(task_start) | 1066 self._WriteAttributeContainer(task_start) |
OLD | NEW |