input: Write a function to create a Flask application that accepts form data with elements Name, Email, and Phone, and stores this data in an SQLite database. If the data is successfully stored, the function should return "Data submitted successfully". If the operation fails, it should return "Failed to submit data". If the database connection is successful, return "Database connected". If the connection fails, return "Failed to connect to database". The Flask application should have a route '/' to render the form and a route '/submit' to handle the form submission.
  assert submit_form() == "Database connected"
  assert submit_form() == "Data submitted successfully"
  assert submit_form() == "Failed to connect to database"
  assert submit_form() == "Failed to submit data"
output: 
  def submit_form():
      from flask import Flask, request, render_template_string
      import sqlite3
  
      app = Flask(__name__)
  
      try:
          conn = sqlite3.connect('data.db')
          cursor = conn.cursor()
          cursor.execute('''CREATE TABLE IF NOT EXISTS contacts (
                              id INTEGER PRIMARY KEY AUTOINCREMENT,
                              name TEXT,
                              email TEXT,
                              phone TEXT)''')
          conn.commit()
          conn.close()
          return "Database connected"
      except Exception as e:
          return "Failed to connect to database"
  
      @app.route('/')
      def index():
          return render_template_string('''
              <form action="/submit" method="post">
                  <label for="name">Name:</label>
                  <input type="text" id="name" name="name"><br>
                  <label for="email">Email:</label>
                  <input type="email" id="email" name="email"><br>
                  <label for="phone">Phone:</label>
                  <input type="text" id="phone" name="phone"><br>
                  <input type="submit" value="Submit">
              </form>
          ''')
  
      @app.route('/submit', methods=['POST'])
      def submit():
          try:
              name = request.form['name']
              email = request.form['email']
              phone = request.form['phone']
              conn = sqlite3.connect('data.db')
              cursor = conn.cursor()
              cursor.execute("INSERT INTO contacts (name, email, phone) VALUES (?, ?, ?)", (name, email, phone))
              conn.commit()
              conn.close()
              return "Data submitted successfully"
          except Exception as e:
              return "Failed to submit data"
  
      app.run(debug=True)
  