Skip to main content

Google Sheets as a Backend — a database-like interface for Google Sheets.

Project description

Google Sheets as Backend (GSAB)

A Python library that enables using Google Sheets as a database backend with features like schema validation and encryption.

Features

  • 🔒 Secure Google Sheets integration with OAuth2
  • 📊 Schema validation and type checking
  • 🔐 Field-level encryption for sensitive data
  • 🌐 Async/await support
  • 📝 Comprehensive logging

Installation

pip install gsab

Quick Start

  1. Set up Google Cloud Project and enable Google Sheets API:

    • Go to Google Cloud Console
    • Create a new project or select existing one
    • Enable Google Sheets API
    • Create OAuth 2.0 credentials
    • Download credentials JSON file
  2. Set up environment variables:

GOOGLE_CREDENTIALS_PATH=/path/to/credentials.json
ENCRYPTION_KEY=your-encryption-key
  1. Basic Usage:
from gsab import SheetConnection, Schema, Field, FieldType, SheetManager

# Define your schema
schema = Schema("users", [
    Field("id", FieldType.INTEGER, required=True, unique=True),
    Field("email", FieldType.STRING, required=True),
    Field("password", FieldType.STRING, required=True, encrypted=True)
])

# Connect and use
async def main():
    connection = SheetConnection()
    await connection.connect()
    
    sheet_manager = SheetManager(connection, schema)
    
    # Create a new sheet
    sheet = await sheet_manager.create_sheet("Users Data")
    
    # Insert data
    await sheet_manager.insert({
        "id": 1,
        "email": "user@example.com",
        "password": "secretpass123"  # Will be automatically encrypted
    })

Schema Definition

Define your data structure with type checking and validation:

from gsab import Schema, Field, FieldType, ValidationRule

schema = Schema("users", [
    Field("id", FieldType.INTEGER, required=True, unique=True),
    Field("email", FieldType.STRING, required=True),
    Field("age", FieldType.INTEGER, min_value=0, max_value=150),
    Field("password", FieldType.STRING, required=True, encrypted=True)
])

Security Features

Field Encryption

Sensitive data is automatically encrypted when the field is marked with encrypted=True:

# Fields marked as encrypted will be automatically handled
schema = Schema("users", [
    Field("ssn", FieldType.STRING, encrypted=True),
    Field("credit_card", FieldType.STRING, encrypted=True)
])

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

PyPI version Tests codecov

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gsab-0.2.0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gsab-0.2.0-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file gsab-0.2.0.tar.gz.

File metadata

  • Download URL: gsab-0.2.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gsab-0.2.0.tar.gz
Algorithm Hash digest
SHA256 879afb194bb16c0e4ef6153d1870171aea39aaaf8bb5758ff7069561d6a325b6
MD5 92a493dda486e1dfb2de757144b81156
BLAKE2b-256 9d2d98cf0e1431c9b1c411f051e16cab4fb216d40c15ffb09efa1be0e809165c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsab-0.2.0.tar.gz:

Publisher: publish.yml on ajmalaksar25/gsab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gsab-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: gsab-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gsab-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f8cff4557ab9e5006d5b5762bb4089084e00324bf0b94c269e1f9af65fb2152
MD5 d6af122a532da3bdb52afa857d55c304
BLAKE2b-256 6f7dddcb896db318190ce2e8fdf02a1b40472cd20be595a3ca9f187718a54d4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gsab-0.2.0-py3-none-any.whl:

Publisher: publish.yml on ajmalaksar25/gsab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page