code: def upsert_skill(skill: Skill, dbmanager: DBManager) -> List[Skill]:
      """
      Insert or update a skill for a specific user in the database.
  
      If the skill with the given ID already exists, it will be updated with the new data.
      Otherwise, a new skill will be created.
  
      :param  skill: The Skill object containing skill data
      :param dbmanager: The DBManager instance to interact with the database
      :return: A list of dictionaries, each representing a skill
      """
  
      existing_skill = get_item_by_field(
          "skills", "id", skill.id, dbmanager
      )
  
      if existing_skill:
          updated_data = {
              "user_id": skill.user_id,
              "timestamp": skill.timestamp,
              "content": skill.content,
              "title": skill.title,
              "file_name": skill.file_name,
          }
          update_item("skills", skill.id, updated_data, dbmanager)
      else:
          query = "INSERT INTO skills (id, user_id, timestamp, content, title, file_name) VALUES (?, ?, ?, ?, ?, ?)"
          args = (
              skill.id,
              skill.user_id,
              skill.timestamp,
              skill.content,
              skill.title,
              skill.file_name,
          )
          dbmanager.query(query=query, args=args)
  
      skills = get_skills(user_id=skill.user_id, dbmanager=dbmanager)
  
      return skills
  
imports: import json
  import logging
  import sqlite3
  import threading
  import os
  from typing import Any, List, Dict, Optional, Tuple
  from ..datamodel import AgentFlowSpec, AgentWorkFlowConfig, Gallery, Message, Session, Skill
label_desc: Use image node_id 9 for calling a global function with example usage: upsert_skill(skill, dbmanager) and returns: skills