input: Write a python function to insert data from an API into a SQLite database.
  assert insert_data_from_api('http://example.com/api/data', 'test.db', 'table_name', ['column1', 'column2', 'column3'])==True
  assert insert_data_from_api('http://example.com/api/other_data', 'other_test.db', 'other_table', ['col1', 'col2', 'col3'])==True
output: import sqlite3
  import requests
  
  def insert_data_from_api(api_url, db_name, table_name, columns):
      try:
          response = requests.get(api_url)
          response.raise_for_status()
          data = response.json()
  
          conn = sqlite3.connect(db_name)
          cursor = conn.cursor()
  
          placeholders = ', '.join(['?'] * len(columns))
          column_names = ', '.join(columns)
          query = f"INSERT INTO {table_name} ({column_names}) VALUES ({placeholders})"
  
          for item in data:
              values = tuple(item[col] for col in columns)
              cursor.execute(query, values)
  
          conn.commit()
          conn.close()
          return True
      except Exception as e:
          print(f"An error occurred: {e}")
          return False