From 3adda8c01aa6c1580f1470aef428193188ccf043 Mon Sep 17 00:00:00 2001 From: Max Usachev Date: Tue, 15 Jun 2010 13:21:43 +0300 Subject: [PATCH] fixed SCHEMA error --- database/SQLite.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/database/SQLite.py b/database/SQLite.py index b5e9514..28229cb 100644 --- a/database/SQLite.py +++ b/database/SQLite.py @@ -15,31 +15,28 @@ SCHEMA = """ 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; """ @@ -50,19 +47,22 @@ class SQLite: 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): -- 1.7.9.5