class_docstr: Access the history database without adding to it.
  
  This is intended for use by standalone history tools. IPython shells use
  HistoryManager, below, which is a subclass of this.
class_docstr_tok: ["Access","the","history","database","without","adding","to","it",".","This","is","intended","for","use","by","standalone","history","tools",".","IPython","shells","use","HistoryManager",",","below",",","which","is","a","subclass","of","this","."]
docstr: Connect to the database, and create tables if necessary.
docstr_tok: ["Connect","to","the","database",",","and","create","tables","if","necessary","."]
code: def init_db(self):
      """Connect to the database, and create tables if necessary."""
      if not self.enabled:
          self.db = DummyDB()
          return
  
      # use detect_types so that timestamps return datetime objects
      kwargs = dict(
          detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES
      )
      kwargs.update(self.connection_options)
      self.db = sqlite3.connect(str(self.hist_file), **kwargs)
      with self.db:
          self.db.execute(
              """CREATE TABLE IF NOT EXISTS sessions (session integer
                              primary key autoincrement, start timestamp,
                              end timestamp, num_cmds integer, remark text)"""
          )
          self.db.execute(
              """CREATE TABLE IF NOT EXISTS history
                      (session integer, line integer, source text, source_raw text,
                      PRIMARY KEY (session, line))"""
          )
          # Output history is optional, but ensure the table's there so it can be
          # enabled later.
          self.db.execute(
              """CREATE TABLE IF NOT EXISTS output_history
                              (session integer, line integer, output text,
                              PRIMARY KEY (session, line))"""
          )
      # success! reset corrupt db count
      self._corrupt_db_counter = 0
  
imports: import atexit
  import datetime
  from pathlib import Path
  import re
  import sqlite3
  import threading
  from traitlets.config.configurable import LoggingConfigurable
  from decorator import decorator
  from IPython.utils.decorators import undoc
  from IPython.paths import locate_profile
  from traitlets import Any, Bool, Dict, Instance, Integer, List, Unicode, Union, TraitError, default, observe
label_desc: Use image node_id 5 for calling the HistoryAccessor obj's underlying member method code with example usage: obj.init_db() without return types