input: Write a function to create a REST API with Flask that allows users to create, read, update, and delete records from a database. The function should define the necessary Flask routes, database models, and configurations.
  
  assert create_rest_api()==True
  assert create_rest_api()==True
  assert create_rest_api()==True
  assert create_rest_api()==True
  assert create_rest_api()==True
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:///test.db'
      db = SQLAlchemy(app)
  
      class Record(db.Model):
          id = db.Column(db.Integer, primary_key=True)
          data = db.Column(db.String(100), nullable=False)
  
          def to_dict(self):
              return {'id': self.id, 'data': self.data}
  
      @app.route('/records', methods=['POST'])
      def create_record():
          data = request.json.get('data')
          if not data:
              return jsonify({'error': 'Data is required'}), 400
          new_record = Record(data=data)
          db.session.add(new_record)
          db.session.commit()
          return jsonify(new_record.to_dict()), 201
  
      @app.route('/records', methods=['GET'])
      def read_records():
          records = Record.query.all()
          return jsonify([record.to_dict() for record in records]), 200
  
      @app.route('/records/<int:id>', methods=['GET'])
      def read_record(id):
          record = Record.query.get(id)
          if not record:
              return jsonify({'error': 'Record not found'}), 404
          return jsonify(record.to_dict()), 200
  
      @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.json.get('data')
          if not data:
              return jsonify({'error': 'Data is required'}), 400
          record.data = data
          db.session.commit()
          return jsonify(record.to_dict()), 200
  
      @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({'message': 'Record deleted'}), 200
  
      db.create_all()
      return True