code: import argparse
  from pathlib import Path
  from random import sample
  from typing import Any, Optional
  
  import lancedb
  import pandas as pd
  
  from schema import Myntra
  
  
  def create_table(
      database: str,
      table_name: str,
      data_path: str,
      schema: Any = Myntra,
      mode: str = "overwrite",
  ) -> None:
      """
      Create a table in the specified vector database and add data to it.
  
      Args:
          database (str): The name of the database to connect to.
          table_name (str): The name of the table to create.
          data_path (str): The path to the data directory.
          schema (Schema, optional): The schema to use for the table. Defaults to Myntra.
          mode (str, optional): The mode for creating the table. Defaults to "overwrite".
  
      Returns:
          None
  
      Usage:
      >>> create_table(database="~/.lancedb"", table_name="myntra", data_path="input")
      """
  
      # Connect to the lancedb database
      db = lancedb.connect(database)
  
      # Check if the table already exists in the database
      if table_name in db:
          print(f"Table {table_name} already exists in the database")
          table = db[table_name]
  
      # if it does not exist then create a new table
      else:
  
          print(f"Creating table {table_name} in the database")
  
          # Create the table with the given schema
          table = db.create_table(table_name, schema=schema, mode=mode)
  
          # Define the Path of the images and obtain the Image uri
          p = Path(data_path).expanduser()
          uris = [str(f) for f in p.glob("*.jpg")]
          print(f"Found {len(uris)} images in {p}")
  
          # Sample 1000 images from the data
          # Increase this value for more accurate results but
          # it will take more time to process embeddings
          uris = sample(uris, 1000)
  
          # Add the data to the table
          print(f"Adding {len(uris)} images to the table")
          table.add(pd.DataFrame({"image_uri": uris}))
          print(f"Added {len(uris)} images to the table")
  
  
  if __name__ == "__main__":
      parser = argparse.ArgumentParser(
          description="Create a table in lancedb with Myntra data"
      )
      parser.add_argument(
          "database", help="Path to the lancedb database", default="path/to/database"
      )
      parser.add_argument(
          "table_name", help="Name of the table to be created", default="my_table"
      )
      parser.add_argument(
          "data_path", help="Path to the Myntra data images", default="path/to/data"
      )
      args = parser.parse_args()
  
      create_table(args.database, args.table_name, args.data_path)
  
apis: lancedb.connect
extract_api: [((936, 961), 'lancedb.connect', 'lancedb.connect', (['database'], {}), '(database)\n', (951, 961), False, 'import lancedb\n'), ((2032, 2118), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""Create a table in lancedb with Myntra data"""'}), "(description=\n    'Create a table in lancedb with Myntra data')\n", (2055, 2118), False, 'import argparse\n'), ((1768, 1786), 'random.sample', 'sample', (['uris', '(1000)'], {}), '(uris, 1000)\n', (1774, 1786), False, 'from random import sample\n'), ((1899, 1932), 'pandas.DataFrame', 'pd.DataFrame', (["{'image_uri': uris}"], {}), "({'image_uri': uris})\n", (1911, 1932), True, 'import pandas as pd\n'), ((1466, 1481), 'pathlib.Path', 'Path', (['data_path'], {}), '(data_path)\n', (1470, 1481), False, 'from pathlib import Path\n')]