X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Fdb.py;h=98e541e95732378344f2e6f47b6b5f2cb1af2f3c;hb=e94c6883c5c71b05b82db32583cb05dac4091907;hp=c77e32fc554a092f18dfddaf6d782ce2efa0560b;hpb=09e86eb1db8af5421f8ce0501ec13a520d9648ff;p=m_librarian.git 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():