docs: def dump_table_as_insert_sql(engine: Engine,
                               table_name: str,
                               fileobj: TextIO,
                               wheredict: Dict[str, Any] = None,
                               include_ddl: bool = False,
                               multirow: bool = False) -> None:
      """
      Reads a table from the database, and writes SQL to replicate the table's
      data to the output ``fileobj``.
  
      Args:
          engine: SQLAlchemy :class:`Engine`
          table_name: name of the table
          fileobj: file-like object to write to
          wheredict: optional dictionary of ``{column_name: value}`` to use as
              ``WHERE`` filters
          include_ddl: if ``True``, include the DDL to create the table as well
          multirow: write multi-row ``INSERT`` statements
      """
      # http://stackoverflow.com/questions/5631078/sqlalchemy-print-the-actual-query  # noqa
      # http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html
      # http://www.tylerlesmann.com/2009/apr/27/copying-databases-across-platforms-sqlalchemy/  # noqa
      # https://github.com/plq/scripts/blob/master/pg_dump.py
      log.info("dump_data_as_insert_sql: table_name={}", table_name)
      writelines_nl(fileobj, [
          SEP1,
          sql_comment("Data for table: {}".format(table_name)),
          SEP2,
          sql_comment("Filters: {}".format(wheredict)),
      ])
      dialect = engine.dialect
      if not dialect.supports_multivalues_insert:
          multirow = False
      if multirow:
          log.warning("dump_data_as_insert_sql: multirow parameter substitution "
                      "not working yet")
          multirow = False
  
      # literal_query = make_literal_query_fn(dialect)
  
      meta = MetaData(bind=engine)
      log.debug("... retrieving schema")
      table = Table(table_name, meta, autoload=True)
      if include_ddl:
          log.debug("... producing DDL")
          dump_ddl(table.metadata, dialect_name=engine.dialect.name,
                   fileobj=fileobj)
      # NewRecord = quick_mapper(table)
      # columns = table.columns.keys()
      log.debug("... fetching records")
      # log.debug("meta: {}", meta)  # obscures password
      # log.debug("table: {}", table)
      # log.debug("table.columns: {!r}", table.columns)
      # log.debug("multirow: {}", multirow)
      query = select(table.columns)
      if wheredict:
          for k, v in wheredict.items():
              col = table.columns.get(k)
              query = query.where(col == v)
      # log.debug("query: {}", query)
      cursor = engine.execute(query)
      if multirow:
          row_dict_list = []
          for r in cursor:
              row_dict_list.append(dict(r))
          # log.debug("row_dict_list: {}", row_dict_list)
          if row_dict_list:
              statement = table.insert().values(row_dict_list)
              # log.debug("statement: {!r}", statement)
              # insert_str = literal_query(statement)
              insert_str = get_literal_query(statement, bind=engine)
              # NOT WORKING FOR MULTIROW INSERTS. ONLY SUBSTITUTES FIRST ROW.
              writeline_nl(fileobj, insert_str)
          else:
              writeline_nl(fileobj, sql_comment("No data!"))
      else:
          found_one = False
          for r in cursor:
              found_one = True
              row_dict = dict(r)
              statement = table.insert(values=row_dict)
              # insert_str = literal_query(statement)
              insert_str = get_literal_query(statement, bind=engine)
              # log.debug("row_dict: {}", row_dict)
              # log.debug("insert_str: {}", insert_str)
              writeline_nl(fileobj, insert_str)
          if not found_one:
              writeline_nl(fileobj, sql_comment("No data!"))
      writeline_nl(fileobj, SEP2)
      log.debug("... done")