Skip to main content

Sheet2db

Sheet2db is a tiny python library for one-way syncing the Google spreadsheet to database. (Currently, it supports only MySQL)

It is useful for managing some static data on Google spreadsheet, but also want to sync the sheet data to database.

Sheet2db DOES NOT collect any your secret values!

Installation

pip install sheet2db

Usage

You must have API key which is accessible to Google Spreadsheet API

Example sheet format (items tab):

===========================
|  A |    B |     C |   D |
===========================
| id | name | count | ver |
|----|------|-------|-----|
| .. | .... | ..... | ... |
===========================

Following example will sync items tab of 1U3un2ZJPRhLrWzc2DMXq8VI7Nqf9pYlajfO4mQVCZpE spreadsheet to database:

"AIzaSyC6pabjqmaPiguYoHbq4W7a0DV0wQg5JGk" is a fake api key

from sheet2db import Sheet2db

# Pass API key
syncer = Sheet2db(api_key='AIzaSyC6pabjqmaPiguYoHbq4W7a0DV0wQg5JGk')

# If you need to access to private spreadsheet, you can't use API key. Use oauth credentials instead.
syncer = Sheet2db(
    creds_path='credentials.json',
    token_path='token.json')

# Fetch data from spreadsheet
syncer.fetch(
    sheet='1U3un2ZJPRhLrWzc2DMXq8VI7Nqf9pYlajfO4mQVCZpE',
    tab='items',
    range='A1:D')

# Sync fetched data to database (mysql)
syncer.sync(
    host='192.168.168.10',
    port=3306,
    user='mingrammer',
    password='p@ssw0rd',
    db='static',
    table='items')

You can also use ssh tunneling to access to remote database with sshtunnel

with sshtunnel.SSHTunnelForwarder(
    ('db.service.io', 22),
    ssh_username='ssh_user'
    ssh_pkey='~/.ssh/id_rsa'
    ssh_private_key_password='ssh_pk_password',
    remote_bind_address=('localhost', 3306),
) as tunnel:
    syncer.sync(
        host = tunnel.local_bind_host,
        port = tunnel.local_bind_host,
        user = 'mingrammer',
        password = 'p@ssw0rd',
        db = 'static',
        table = 'items')

License

MIT

Metadata

Release files for sheet2db 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sheet2db 1.0.0
File Size Uploaded Provenance Actions
sheet2db-1.0.0.tar.gz 4.2 kB Without provenance Details for sheet2db-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sheet2db 1.0.0
File Interpreter ABI Platform Actions
sheet2db-1.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for sheet2db-1.0.0-py2.py3-none-any.whl

Total release size: 8.0 kB

Release files / sheet2db-1.0.0.tar.gz

Download URL sheet2db-1.0.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d8edaf224c3adfa72c15d5849a635b67e11ca08b697c1c5ccbd5fee751fa8b91
BLAKE2b-256 checksum
How to use checksums
e5405b9f272c06a6dcc372f421382401c4e51384dead9c9470b72b92de338ac1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release files / sheet2db-1.0.0-py2.py3-none-any.whl

Download URL sheet2db-1.0.0-py2.py3-none-any.whl
Size 3.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3afa32698f651e8dae5459757ea0c58d9689d7ff94267f527aade0caf29ace7e
BLAKE2b-256 checksum
How to use checksums
997719beeb17953bea1644483ce84125596caa5c56cda171eb45811af67d0228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Security for sheet2db 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page