Co-Pilot / 辅助式
更新于 25 days ago

gsheet-crud

Vvkboo
0.0k
vkboo/gsheet-crud
76
Agent 评分

💡 摘要

一个使用Google Sheets作为轻量级数据库的RESTful API服务,支持CRUD操作。

🎯 适合人群

寻找简单数据库解决方案的开发者需要轻量级数据管理的小型企业希望快速访问电子表格数据的数据分析师构建项目时需要最小后端设置的学生

🤖 AI 吐槽:看起来很能打,但别让配置把人劝退。

安全分析中风险

风险:Medium。建议检查:是否执行 shell/命令行指令;是否发起外网请求(SSRF/数据外发);文件读写范围与路径穿越风险;依赖锁定与供应链风险。以最小权限运行,并在生产环境启用前审计代码与依赖。

GSheet-CRUD

A Google Sheets RESTful API service based on sheetsql, using Google Sheets as a database with full CRUD operations.

Features

  • Use Google Sheets as a lightweight database
  • Standard RESTful API (GET/POST/PUT/DELETE)
  • Support query parameters for data filtering
  • Built with Next.js, supports one-click deployment to Vercel

Prerequisites

1. Share Google Sheets Permission

Important: You must add the following service account email as an Editor to your Google Sheets, otherwise reading and writing data will not work:

gsheett-younami@woven-fountain-458301-p7.iam.gserviceaccount.com

Steps:

  1. Open your Google Sheets document
  2. Click the "Share" button in the top right corner
  3. Paste the above email address in the "Add people" input field
  4. Set the permission to "Editor"
  5. Click "Done"

2. Prepare Sheet Data

  • The first row of the sheet must be column names (field names)
  • Data starts from the second row

Example sheet structure:

| name | age | email | |------|-----|-------| | John | 25 | john@example.com | | Jane | 30 | jane@example.com |

API Usage

URL Format

/{doc_id}/{sheet_name}
  • doc_id: Google Sheets document ID (can be found in the URL: https://docs.google.com/spreadsheets/d/{doc_id}/edit)
  • sheet_name: Sheet name (optional, defaults to Sheet1)

Query Data (GET)

Get all data:

GET /{doc_id}/{sheet_name}

Query with conditions:

GET /{doc_id}/{sheet_name}?name=John&age=25

Insert Data (POST)

Insert a single record:

POST /{doc_id}/{sheet_name} Content-Type: application/json { "name": "Mike", "age": 28, "email": "mike@example.com" }

Insert multiple records:

POST /{doc_id}/{sheet_name} Content-Type: application/json [ {"name": "Mike", "age": 28, "email": "mike@example.com"}, {"name": "Sarah", "age": 35, "email": "sarah@example.com"} ]

Update Data (PUT)

Match data to update using query parameters:

PUT /{doc_id}/{sheet_name}?name=John Content-Type: application/json { "age": 26, "email": "new_email@example.com" }

Delete Data (DELETE)

Match data to delete using query parameters:

DELETE /{doc_id}/{sheet_name}?name=John

Local Development

Install Dependencies

npm install # or yarn install

Configure Service Account

Save the Google Cloud service account JSON key file as google-serviceaccount.json in the project root directory.

Start Development Server

npm run dev # or yarn dev

The service will start at http://localhost:3000.

Deployment

Deploy to Vercel (Recommended)

  1. Push the project to GitHub
  2. Import the project in Vercel
  3. Add environment variable in project settings under "Environment Variables":
    • Name: GOOGLE_SERVICE_ACCOUNT_CREDENTIALS
    • Value: Paste the complete contents of google-serviceaccount.json file
  4. Click Deploy

Other Deployment Methods

Build for production:

npm run build

Start production server:

npm run start

Note: When deploying in non-Vercel environments, ensure you configure the service account credentials using one of these methods:

  • Set environment variable GOOGLE_SERVICE_ACCOUNT_CREDENTIALS (value is the JSON file content)
  • Or place the google-serviceaccount.json file in the project root directory

Tech Stack

  • Next.js - React full-stack framework
  • sheetsql - Google Sheets database operation library
  • qs - URL query string parsing

Related Links

License

MIT

五维分析
清晰度8/10
创新性6/10
实用性9/10
完整性8/10
可维护性7/10
优缺点分析

优点

  • 与Google Sheets的设置和使用简单
  • 支持标准的RESTful API操作
  • 轻量且具有成本效益的解决方案

缺点

  • 对于较大数据集的可扩展性有限
  • 依赖于Google Sheets的性能
  • 需要正确配置服务账户

相关技能

pytorch

S
toolCode Lib / 代码库
92/ 100

“它是深度学习的瑞士军刀,但祝你好运能从47种安装方法里找到那个不会搞崩你系统的那一个。”

agno

S
toolCode Lib / 代码库
90/ 100

“它承诺成为智能体领域的Kubernetes,但得看开发者有没有耐心学习又一个编排层。”

nuxt-skills

S
toolCo-Pilot / 辅助式
90/ 100

“这本质上是一份组织良好的小抄,能把你的 AI 助手变成一只 Nuxt 框架的复读机。”

免责声明:本内容来源于 GitHub 开源项目,仅供展示和评分分析使用。

版权归原作者所有 vkboo.