]> git.phdru.name Git - m_librarian.git/blobdiff - m_librarian/db.py
Docs: Recode README.rus.txt to utf-8
[m_librarian.git] / m_librarian / db.py
index ecabfdbcfd146cf583ea2d8aa6dcfe1e1a7d1be0..d81619da0d39e92e14d05bd7b8bd7e6546cbc109 100755 (executable)
@@ -5,6 +5,7 @@ import os
 from sqlobject import SQLObject, StringCol, UnicodeCol, IntCol, BoolCol, \
     ForeignKey, DateCol, DatabaseIndex, RelatedJoin, \
     connectionForURI, sqlhub, SQLObjectNotFound, dberrors
+from .compat import string_type
 from .config import get_config
 
 __all__ = ['Author', 'Book', 'Extension', 'Genre', 'Language',
@@ -146,7 +147,7 @@ def open_db(db_uri=None):
     if db_uri is None:
         try:
             db_uri = get_config().get('database', 'URI')
-        except:
+        except Exception:
             db_uri = find_sqlite_dburi()
 
     if '://' not in db_uri:
@@ -156,7 +157,7 @@ def open_db(db_uri=None):
 
     if connection.dbName == 'sqlite':
         def lower(s):
-            if isinstance(s, basestring):
+            if isinstance(s, string_type):
                 return s.lower()
             return s
 
@@ -224,5 +225,6 @@ def test():
     print("DB dirs:", db_dirs)
     print("DB URI:", find_sqlite_dburi())
 
+
 if __name__ == '__main__':
     test()