code: def cli():
      supported_formats = (
          "csv tsv json yaml html xls xlsx dbf latex ods".split()
      )
      formats_lst = ", ".join(supported_formats)
      cli_docs = """Records: SQL for Humans™
  A Kenneth Reitz project.
  
  Usage:
    records <query> [<format>] [<params>...] [--url=<url>]
    records (-h | --help)
  
  Options:
    -h --help     Show this screen.
    --url=<url>   The database URL to use. Defaults to $DATABASE_URL.
  
  Supported Formats:
     %(formats_lst)s
  
     Note: xls, xlsx, dbf, and ods formats are binary, and should only be
           used with redirected output e.g. '$ records sql xls > sql.xls'.
  
  Query Parameters:
      Query parameters can be specified in key=value format, and injected
      into your query in :key format e.g.:
  
      $ records 'select * from repos where language ~= :lang' lang=python
  
  Notes:
    - While you may specify a database connection string with --url, records
      will automatically default to the value of $DATABASE_URL, if available.
    - Query is intended to be the path of a SQL file, however a query string
      can be provided instead. Use this feature discernfully; it's dangerous.
    - Records is intended for report-style exports of database queries, and
      has not yet been optimized for extremely large data dumps.
      """ % dict(
          formats_lst=formats_lst
      )
  
      # Parse the command-line arguments.
      arguments = docopt(cli_docs)
  
      query = arguments["<query>"]
      params = arguments["<params>"]
      format = arguments.get("<format>")
      if format and "=" in format:
          del arguments["<format>"]
          arguments["<params>"].append(format)
          format = None
      if format and format not in supported_formats:
          print("%s format not supported." % format)
          print("Supported formats are %s." % formats_lst)
          exit(62)
  
      # Can't send an empty list if params aren't expected.
      try:
          params = dict([i.split("=") for i in params])
      except ValueError:
          print("Parameters must be given in key=value format.")
          exit(64)
  
      # Be ready to fail on missing packages
      try:
          # Create the Database.
          db = Database(arguments["--url"])
  
          # Execute the query, if it is a found file.
          if os.path.isfile(query):
              rows = db.query_file(query, **params)
  
          # Execute the query, if it appears to be a query string.
          elif len(query.split()) > 2:
              rows = db.query(query, **params)
  
          # Otherwise, say the file wasn't found.
          else:
              print("The given query could not be found.")
              exit(66)
  
          # Print results in desired format.
          if format:
              content = rows.export(format)
              if isinstance(content, bytes):
                  print_bytes(content)
              else:
                  print(content)
          else:
              print(rows.dataset)
      except ImportError as impexc:
          print(impexc.msg)
          print(
              "Used database or format require a package, which is missing."
          )
          print("Try to install missing packages.")
          exit(60)
  
imports: import os
  from sys import stdout
  from collections import OrderedDict
  from contextlib import contextmanager
  from inspect import isclass
  import tablib
  from docopt import docopt
  from sqlalchemy import create_engine, exc, inspect, text
label_desc: Use image node_id 3 for calling a global function with example usage: cli() without return types