From e94c6883c5c71b05b82db32583cb05dac4091907 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 24 Dec 2015 18:13:02 +0300 Subject: [PATCH] Add indices --- m_librarian/db.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/m_librarian/db.py b/m_librarian/db.py index c77e32f..98e541e 100755 --- a/m_librarian/db.py +++ b/m_librarian/db.py @@ -1,12 +1,12 @@ #! /usr/bin/env python __all__ = ['Author', 'Book', 'Extension', 'Genre', 'Language', - 'init_db', 'insert_name', + 'init_db', 'insert_name', 'update_counters', ] import os from sqlobject import SQLObject, StringCol, UnicodeCol, IntCol, BoolCol, \ - ForeignKey, DateCol, RelatedJoin, \ + ForeignKey, DateCol, DatabaseIndex, RelatedJoin, \ connectionForURI, sqlhub, SQLObjectNotFound, dberrors from .config import ml_conf @@ -54,6 +54,7 @@ if connection.dbName == 'sqlite': class Author(SQLObject): name = UnicodeCol(unique=True) count = IntCol() + count_idx = DatabaseIndex('count') books = RelatedJoin('Book', otherColumn='book_id') @@ -71,23 +72,27 @@ class Book(SQLObject): extension = ForeignKey('Extension') date = DateCol() language = ForeignKey('Language') + archive_file_idx = DatabaseIndex('archive', 'file', unique=True) class Extension(SQLObject): name = StringCol(unique=True) count = IntCol() + count_idx = DatabaseIndex('count') class Genre(SQLObject): name = StringCol(unique=True) title = UnicodeCol() count = IntCol() + count_idx = DatabaseIndex('count') books = RelatedJoin('Book', otherColumn='book_id') class Language(SQLObject): name = StringCol(unique=True) count = IntCol() + count_idx = DatabaseIndex('count') def init_db(): -- 2.39.5