input: Write a function to create a REST API using Flask and SQLAlchemy that enables users to perform CRUD operations on a database. If the API is successfully created, it should return True, otherwise it should return False. If the database is empty, the function should return 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 Item(db.Model):
          id = db.Column(db.Integer, primary_key=True)
          name = db.Column(db.String(80), nullable=False)
  
      db.create_all()
  
      @app.route('/items', methods=['POST'])
      def create_item():
          data = request.get_json()
          new_item = Item(name=data['name'])
          db.session.add(new_item)
          db.session.commit()
          return jsonify({'id': new_item.id, 'name': new_item.name}), 201
  
      @app.route('/items', methods=['GET'])
      def get_items():
          items = Item.query.all()
          return jsonify([{'id': item.id, 'name': item.name} for item in items]), 200
  
      @app.route('/items/<int:id>', methods=['PUT'])
      def update_item(id):
          item = Item.query.get(id)
          if not item:
              return jsonify({'error': 'Item not found'}), 404
          data = request.get_json()
          item.name = data['name']
          db.session.commit()
          return jsonify({'id': item.id, 'name': item.name}), 200
  
      @app.route('/items/<int:id>', methods=['DELETE'])
      def delete_item(id):
          item = Item.query.get(id)
          if not item:
              return jsonify({'error': 'Item not found'}), 404
          db.session.delete(item)
          db.session.commit()
          return jsonify({'result': 'Item deleted'}), 200
  
      if __name__ == '__main__':
          app.run(debug=True)
  
      return True
  