def _make_mdd_index(self, db_name): mdd = MDD(self._mdd_file) self._mdd_db = db_name index_list = mdd.get_index() conn = sqlite3.connect(db_name) c = conn.cursor() c.execute(''' CREATE TABLE MDX_INDEX (key_text text, file_pos integer, compressed_size integer, record_block_type integer, record_start integer, record_end integer, offset integer )''') tuple_list = [] for item in index_list: tuple = (item['key_text'], item['file_pos'], item['compressed_size'], item['record_block_type'], item['record_start'], item['record_end'], item['offset']) tuple_list.append(tuple) c.executemany('INSERT INTO MDX_INDEX VALUES (?,?,?,?,?,?,?)', tuple_list) conn.commit() conn.close()
def _make_mdd_index(self, db_name): if os.path.exists(db_name): os.remove(db_name) mdd = MDD(self._mdd_file) self._mdd_db = db_name index_list = mdd.get_index(check_block=self._check) conn = sqlite3.connect(db_name) c = conn.cursor() c.execute(''' CREATE TABLE MDX_INDEX (key_text text not null unique, file_pos integer, compressed_size integer, decompressed_size integer, record_block_type integer, record_start integer, record_end integer, offset integer )''') tuple_list = [ (item['key_text'], item['file_pos'], item['compressed_size'], item['decompressed_size'], item['record_block_type'], item['record_start'], item['record_end'], item['offset']) for item in index_list ] c.executemany('INSERT INTO MDX_INDEX VALUES (?,?,?,?,?,?,?,?)', tuple_list) if self._sql_index: c.execute(''' CREATE UNIQUE INDEX key_index ON MDX_INDEX (key_text) ''') conn.commit() conn.close()