field_id text,
value text
);
+ create index i_data on data (id);
create table fields(
id integer primary key,
name text
);
+ create index i_fields on fields (id);
create table relation(
data_id integer,
struct_id integer
);
+ create index i_relation_data on relation(data_id);
create table struct(
id integer primary key,
name text,
parent integer
);
-
+ create index i_struct_id on struct(parent);
commit;
- create index i_fields on fields (id);
- create index i_data on data (id);
- create index i_struct_id on parent struct(id);
- create index i_relation_data on relation(data_id);
-
- commit;
"""
if not os.path.exists(self._path):
self.new()
else:
- self.conn = sqlite3.connect(self._path)
+ self.connect()
+
+ def connect(self):
+ """Connects to database."""
+
+ self.conn = sqlite3.connect(self._path, isolation_level="EXCLUSIVE")
def new(self):
"""Creates new databse."""
- self.conn = sqlite3.connect(self._path)
+ self.connect()
self.conn.executescript(SCHEMA)
- self.conn.commit()
def close(self):
"""Closes connection with database."""
- self.conn.commit()
self.conn.close()
def save(self):