code: import json
  import lancedb
  from lancedb.pydantic import Vector, LanceModel
  from datetime import datetime
  
  # import pyarrow as pa
  
  TABLE_NAME = "documents"
  
  uri = "data/sample-lancedb"
  db = lancedb.connect(uri)
  
  
  # vector: list of vectors
  # file_name: name of file
  # file_path: path of file
  # id
  # updated_at
  # created_at
  class Document(LanceModel):
      id: str
      file_name: str
      file_path: str
      created_at: datetime
      updated_at: datetime
      vector: Vector(768)  # Palm Embeddings size
  
  
  try:
      table = db.create_table(TABLE_NAME, schema=Document)
  except OSError:
      print("table exists")
      table = db.open_table(TABLE_NAME)
  except Exception as inst:
      # Print out the type of exceptions.
      print(type(inst))
      print(inst.args)
      print(inst)
  
  if True:
      now = datetime.now()
      # Idempotent upsert. Alternatively we can delete first, then insert.
      table.add(
          [
              Document(
                  id="1",
                  file_name="test_name",
                  file_path="test_path",
                  created_at=now,
                  updated_at=now,
                  vector=[i for i in range(768)],
              )
          ]
      )
      table.delete(f'id="1" AND created_at != timestamp "{now}"')
  
  
  if False:
      table.update(
          where='id="1"',
          values=Document(
              id="1",
              file_name="test_name",
              file_path="test_path",
              created_at=datetime.now(),
              updated_at=datetime.now(),
              vector=[i for i in range(768)],
          ),
      )
  
  vector = [i for i in range(768)]
  result = table.search(vector).limit(2).to_list()
  for item in result:
      print(item)
      # print(json.dumps(item, indent=2))
  
  
  print(db[TABLE_NAME].head())
  
apis: lancedb.pydantic.Vector lancedb.connect
extract_api: [((189, 209), 'lancedb.connect', 'lancedb.connect', (['uri'], {}), '(uri)\n', (204, 209), False, 'import lancedb\n'), ((461, 472), 'lancedb.pydantic.Vector', 'Vector', (['(768)'], {}), '(768)\n', (467, 472), False, 'from lancedb.pydantic import Vector, LanceModel\n'), ((786, 800), 'datetime.datetime.now', 'datetime.now', ([], {}), '()\n', (798, 800), False, 'from datetime import datetime\n'), ((1421, 1435), 'datetime.datetime.now', 'datetime.now', ([], {}), '()\n', (1433, 1435), False, 'from datetime import datetime\n'), ((1460, 1474), 'datetime.datetime.now', 'datetime.now', ([], {}), '()\n', (1472, 1474), False, 'from datetime import datetime\n')]