• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    TypeScript
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Google Spreadsheet as a Database

SheetSQL

npm CircleCI

Google Spreadsheet as a Database.

Purpose

In the past, I often asked by non-technical colleagues to do some DB scripts jobs to mapping their spreadsheets data to the production database. And when their data changes the same work needs to be done again. Since these data are not changed too frequently(compared with other online data), it's also not worth to make a content management system for them.

But why don't make their spreadsheets as a real production database? That's what "Single source of truth" means. What's more, you even could write back some statistical data like "Page View" to the spreadsheets, so they could see the feedback clearly and continue to optimize the content.

Requirements

  1. Create a Google Spreadsheet and populate the first row with the columns names, here is an Example Sheet.
  2. Create a Google Cloud Service Account and download the JSON file that contains your key.
  3. Find your service account email in credentials console which similar with [email protected].
  4. Share your sheets to the above email, and make sure you have assigned it as an editor.

Usage

Concepts

db

db means the Google Spreadsheet ID. You can find it in your sheet's URL: https://docs.google.com/spreadsheets/d/${YOUR_SHEETS_ID}/edit

table

table means the Sheet Name in your Spreadsheet. The default is Sheet1.

data type

Every data in sheetsql will be set/get as a string. You need to handle the type mapping on your side.

keyFile

Your service account JSON key file.

Install

npm i sheetsql -S

Example

const db = new Database({
  db: '1ya2Tl2ev9M80xYwspv7FJaoWq0oVOMBk3VF0f0MXv2s',
  table: 'Sheet1', // optional, default = Sheet1
  keyFile: './google-serviceaccount.json',
  cacheTimeoutMs: 5000, // optional, default = 5000
})

// load schema and data from google spreadsheet
await db.load()

// insert multiple documents
let docs = await db.insert([
  {
    name: 'joway',
    age: 18,
  },
])

// find documents and update them
docs = await db.update(
  {
    name: 'joway',
  },
  {
    age: 100,
  },
)

// find documents
docs = await db.find({
  name: 'joway',
})

// find all documents
docs = await db.find({})

// find documents and remove them
docs = await db.remove({
  name: 'joway',
})

Using a Proxy

sheetsql depend on googleapis lib in which you can set the following environment variables to proxy http/https requests:

  • HTTP_PROXY / http_proxy
  • HTTPS_PROXY / https_proxy

The two environment variables could let your all requests using the proxy. If that is not your expected behavior and you only need to proxy google APIs, set NO_PROXY=*.

Here is the discuss.

More Repositories

1

hugo-theme-yinyang

A black-white theme for Hugo.
HTML
424
star
2

burrow-dashboard

Kafka Dashboard for Burrow 1.0 API, monitor the topic info and consumer group offsets.
Vue
57
star
3

color-cn

Spread Chinese traditional colors to the world.
CSS
34
star
4

node-routine

A library to implement Goroutine-Like API with worker_threads.
TypeScript
32
star
5

elasticsearch-hamming-plugin

hamming distance plugin for elasticsearch 5.x
Java
30
star
6

lemon

An async and lightweight API framework for python.
Python
28
star
7

DeepNeuralNetworkGo

Go / weiqi / 围棋 / 囲碁 / Jeu de go . Fork from
JavaScript
22
star
8

node-kfk

A simplified kafka client based on node-rdkafka.
TypeScript
18
star
9

JPBC_Optimize_IBE

JPBC_Optimize_IBE by JPBC
Java
17
star
10

lsdis

KV storage based on LocalStorage.
TypeScript
17
star
11

jallery

Joway's Gallery
Vue
10
star
12

pond

Generic Object Pool for Golang.
Go
10
star
13

Block

Another blog based on Django . [abandoned]
JavaScript
9
star
14

easy_qiniu

基于七牛官方API封装成的 Client
Python
9
star
15

latex-template-zh

一个符合中文排版要求的 LaTeX 样式模板
TeX
9
star
16

hive

Hive is a high-efficiency goroutine pool based on pond.
Go
8
star
17

Chirp

自建评论系统,替代disqus , 支持 第三方登陆
CSS
7
star
18

flying

Make release easy again .
Python
7
star
19

loki

Minimalist logger for Golang
Go
6
star
20

decision

Decide It ! 🐣
JavaScript
4
star
21

zh-checker

中文错别字检测
Python
4
star
22

qiniu_upload_node

一键上传七牛脚本 node.js
JavaScript
4
star
23

DjangoSeed

Django Seed Project .
Python
4
star
24

fastrand

Go
4
star
25

libimagequant-go

golang wrapper for libimagequant.
C
4
star
26

QiniuImageBox

powered by Qiniu .
Java
4
star
27

HackSearch

hackx.org
JavaScript
3
star
28

socket.io-kfk

Kafka adapter for socket.io
JavaScript
3
star
29

gobber

A Golang helper to access private struct field.
Go
3
star
30

fonts

https://fonts.joway.io/
CSS
3
star
31

PhotoHit

基于图片流的弹幕网站
JavaScript
3
star
32

hexo-tokenize-search

hexo 分词 搜索插件
JavaScript
3
star
33

hugo-blog

HTML
3
star
34

hadoopy

对 hadoop的 MapReduce 与 hdfs 原理 基于 python 的简单模拟实现
Python
3
star
35

docker-orange-kubernetes

orange api gateway for kubernetes
Shell
2
star
36

django-geofield

A lightweight Django Geo Field to save and handle Geo Points with geohash
Python
2
star
37

Dispider

Distributed spider System
JavaScript
2
star
38

wechat-post

post issues by wechat
Python
2
star
39

m2r

convert markdown to phabricator remarkup format
JavaScript
2
star
40

trie

trie implement for golang
Go
2
star
41

CppCodesInLearning

学习过程中写的代码,大部分是简单的样例
HTML
1
star
42

netswatch

Net gathers, and now my watch begins.
HTML
1
star
43

repo-watching

github repo watching framework
Python
1
star
44

blog

HTML
1
star
45

DockerMulti

Lightweight isolation environment among multiple users- base on docker
Python
1
star
46

Asyncer

python 异步任务处理
Python
1
star
47

tech-views

1
star
48

DocumentJSPlugin

Based on i5ting_ztree_toc : https://github.com/i5ting/i5ting_ztree_toc
HTML
1
star
49

timer-exector

Exec events when it hit time wait limit or queue size limit
TypeScript
1
star
50

SpringMVC-Hibernate-Demo

SpringMVC + Hibernate + JPA + ehcache + Junit + spring-mvc-test
Java
1
star
51

TulingRobot-Android

Base on http://tuling123.com API
Java
1
star
52

Django-JWT-User-BaseDemo

Django-JWT-User-BaseDemo
Python
1
star
53

joway

1
star