const pool = {execute(q: any): any {}};

// 标签模板函数
async function sql(queryParts: TemplateStringsArray, ...values: any[]) {
  let query = queryParts.reduce((acc, part, i) => {
    return acc + part + (values[i - 1] ? values[i - 1] : '');
  });

  try {
    const [results] = await pool.execute(query);
    return results;
  } catch (error) {
    console.error('Error executing SQL:', error);
    throw error;
  }
}

export function Button() {
  return (
    <div>
      <button
        formAction={async () => {
          'use server';
          await sql`INSERT INTO users (name, email) VALUES `;
        }}
      >
        提交
      </button>
    </div>
  );
}
