docs: def prettyprintable_sql(statement, dialect=None, reindent=True):
      """
      Generate an SQL expression string with bound parameters rendered inline
      for the given SQLAlchemy statement. The function can also receive a
      `sqlalchemy.orm.Query` object instead of statement.
  
      WARNING: Should only be used for debugging. Inlining parameters is not
               safe when handling user created data.
      """
      if isinstance(statement, sqlalchemy.orm.Query):
          if dialect is None:
              dialect = statement.session.get_bind().dialect
          statement = statement.statement
  
      # Generate a class that can handle encoding
      if dialect:
          DialectKlass = dialect.__class__
      else:
          DialectKlass = DefaultDialect
  
      class LiteralDialect(DialectKlass):
          colspecs = {
              # prevent various encoding explosions
              String: StringLiteral,
              # teach SA about how to literalize a datetime
              DateTime: StringLiteral,
              Date: StringLiteral,
              # don't format py2 long integers to NULL
              NullType: StringLiteral,
          }
  
      compiled = statement.compile(
          dialect=LiteralDialect(), compile_kwargs={
              'literal_binds': True
          }
      )
      return sqlparse.format(str(compiled), reindent=reindent)