parameters: (self, sql, params, raw=True, output=False)
return_statement: return cur
docstring: 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`
docstring_summary: Prepares and runs an SQL query for the history database.
docstring_tokens: Prepares and runs an SQL query for the history database .
function: 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, (inp, out)) for ses, lin, inp, out in cur)
          return cur
function_tokens: def _run_sql ( self , sql , params , raw = True , output = False ) : 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 , ( inp , out ) ) for ses , lin , inp , out in cur ) return cur