diff --git a/IPython/core/history.py b/IPython/core/history.py index 98373f2..66b4aec 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -8,13 +8,7 @@ import atexit import datetime import os import re -try: - import sqlite3 -except ImportError: - try: - from pysqlite2 import dbapi2 as sqlite3 - except ImportError: - sqlite3 = None +import sqlite3 import threading from traitlets.config.configurable import LoggingConfigurable @@ -49,26 +43,8 @@ class DummyDB(object): pass -@decorator -def needs_sqlite(f, self, *a, **kw): - """Decorator: return an empty list in the absence of sqlite.""" - if sqlite3 is None or not self.enabled: - return [] - else: - return f(self, *a, **kw) - - -if sqlite3 is not None: - DatabaseError = sqlite3.DatabaseError - OperationalError = sqlite3.OperationalError -else: - @undoc - class DatabaseError(Exception): - "Dummy exception when sqlite could not be imported. Should never occur." - - @undoc - class OperationalError(Exception): - "Dummy exception when sqlite could not be imported. Should never occur." +DatabaseError = sqlite3.DatabaseError +OperationalError = sqlite3.OperationalError # use 16kB as threshold for whether a corrupt history db should be saved # that should be at least 100 entries or so @@ -302,7 +278,6 @@ class HistoryAccessor(HistoryAccessorBase): return ((ses, lin, (inp, out)) for ses, lin, inp, out in cur) return cur - @needs_sqlite @catch_corrupt_db def get_session_info(self, session): """Get info about a session. @@ -558,7 +533,6 @@ class HistoryManager(HistoryAccessor): profile_dir = self.shell.profile_dir.location return os.path.join(profile_dir, 'history.sqlite') - @needs_sqlite def new_session(self, conn=None): """Get a new session number.""" if conn is None: @@ -769,7 +743,6 @@ class HistoryManager(HistoryAccessor): conn.execute("INSERT INTO output_history VALUES (?, ?, ?)", (self.session_number,)+line) - @needs_sqlite def writeout_cache(self, conn=None): """Write any entries in the cache to the database.""" if conn is None: @@ -818,7 +791,6 @@ class HistorySavingThread(threading.Thread): self.enabled = history_manager.enabled atexit.register(self.stop) - @needs_sqlite def run(self): # We need a separate db connection per thread: try: