input: Write a function to create a Flask-based REST API that allows users to perform CRUD operations on a database. The API should support creating, reading, updating, and deleting records.
  assert create_rest_api() == True
  assert create_rest_api().config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:////tmp/test.db'
  assert create_rest_api().models['Record'].name == db.Column(db.String(120), unique=True)
  assert create_rest_api().routes['/records']['GET'] is not None
  assert create_rest_api().routes['/records']['POST'] is not None
  assert create_rest_api().routes['/records/{id}']['PUT'] is not None
  assert create_rest_api().routes['/records/{id}']['DELETE'] is not None
output: 
  def create_rest_api():
      from flask import Flask, request, jsonify
      from flask_sqlalchemy import SQLAlchemy
  
      app = Flask(__name__)
      app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
      db = SQLAlchemy(app)
  
      class Record(db.Model):
          id = db.Column(db.Integer, primary_key=True)
          name = db.Column(db.String(120), unique=True, nullable=False)
  
      @app.route('/records', methods=['GET'])
      def get_records():
          records = Record.query.all()
          return jsonify([{'id': record.id, 'name': record.name} for record in records])
  
      @app.route('/records', methods=['POST'])
      def create_record():
          data = request.get_json()
          new_record = Record(name=data['name'])
          db.session.add(new_record)
          db.session.commit()
          return jsonify({'id': new_record.id, 'name': new_record.name}), 201
  
      @app.route('/records/<int:id>', methods=['PUT'])
      def update_record(id):
          record = Record.query.get(id)
          if not record:
              return jsonify({'error': 'Record not found'}), 404
          data = request.get_json()
          record.name = data['name']
          db.session.commit()
          return jsonify({'id': record.id, 'name': record.name})
  
      @app.route('/records/<int:id>', methods=['DELETE'])
      def delete_record(id):
          record = Record.query.get(id)
          if not record:
              return jsonify({'error': 'Record not found'}), 404
          db.session.delete(record)
          db.session.commit()
          return jsonify({'result': 'Record deleted'})
  
      app.models = {'Record': Record}
      app.routes = {
          '/records': {'GET': get_records, 'POST': create_record},
          '/records/{id}': {'PUT': update_record, 'DELETE': delete_record}
      }
  
      return app
  