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: Prepares and runs an SQL query for the history database.
  
  Parameters
  ----------
  sql : str
    Any filtering expressions to go after SELECT ... FROM ...
  params : tuple
    Parameters passed to the SQL query (to replace "?")
  raw, output : bool
    See :meth:`get_range`
  
  Returns
  -------
  Tuples as :meth:`get_range`
docstr_tok: ["Prepares","and","runs","an","SQL","query","for","the","history","database",".","Parameters","--","--","--","--","--","sql",":","str","Any","filtering","expressions","to","go","after","SELECT","...","FROM","...","params",":","tuple","Parameters","passed","to","the","SQL","query","(","to","replace","``","?","''",")","raw",",","output",":","bool","See",":","meth",":","`","get_range","`","Returns","--","--","--","-","Tuples","as",":","meth",":","`","get_range","`"]
code: def _run_sql(self, sql, params, raw=True, output=False):
      """Prepares and runs an SQL query for the history database.
  
      Parameters
      ----------
      sql : str
        Any filtering expressions to go after SELECT ... FROM ...
      params : tuple
        Parameters passed to the SQL query (to replace "?")
      raw, output : bool
        See :meth:`get_range`
  
      Returns
      -------
      Tuples as :meth:`get_range`
      """
      toget = "source_raw" if raw else "source"
      sqlfrom = "history"
      if output:
          sqlfrom = (
              "history LEFT JOIN output_history USING (session, line)"
          )
          toget = "history.%s, output_history.output" % toget
      cur = self.db.execute(
          "SELECT session, line, %s FROM %s " % (toget, sqlfrom) + sql,
          params,
      )
      if output:  # Regroup into 3-tuples, and parse JSON
          return (
              (
                  ses,
                  lin,
                  (
                      py3compat.cast_unicode_py2(inp),
                      py3compat.cast_unicode_py2(out),
                  ),
              )
              for ses, lin, inp, out in cur
          )
      return cur
  
imports: from __future__ import print_function
  import atexit
  import datetime
  import os
  import re
  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 IPython.utils import py3compat
  from traitlets import Any, Bool, Dict, Instance, Integer, List, Unicode, TraitError, default, observe
  from warnings import warn
label_desc: Use image node_id 6 for calling the HistoryAccessor obj's underlying member method code with example usage: obj._run_sql(sql, params, raw, output) and returns: cur, unknown