Metadata-Version: 2.2
Name: py-gsheets-db
Version: 0.1.0
Summary: A Python library for using Google Sheets as a database because I felt a need to make it.
Author-email: Abdullah Wasim <abdullahwasimm2112@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Abdullah Wasim
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/yourusername/py-gsheets-db
Project-URL: Repository, https://github.com/yourusername/py-gsheets-db.git
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: google-api-python-client>=2.0.0
Requires-Dist: google-auth-httplib2>=0.1.0
Requires-Dist: google-auth-oauthlib>=0.4.1

# GSheetsDB

A Python library for using Google Sheets as a database. This library provides a simple interface to perform database-like operations on Google Sheets.

## Features

- Simple CRUD operations (Create, Read, Update, Delete)
- Easy to use API
- Type hints for better IDE support
- Comprehensive error handling
- Flexible querying options

## Installation

```bash
pip install py-gsheets-db
```

## Prerequisites

Before using the library, you need to:

1. Set up Google Sheets API:
   - Go to [Google Cloud Console](https://console.cloud.google.com/)
   - Create a new project
   - Enable Google Sheets API
   - Create service account credentials
   - Download the credentials JSON file

2. Create a Google Sheet and get its ID (from the URL)
3. Share your Google Sheet with the service account email (found in your credentials JSON)

## Usage

```python
from py_gsheets_db import GSheetsDB

# Initialize the database
db = GSheetsDB(
    credentials_path='path/to/credentials.json',
    spreadsheet_id='your-spreadsheet-id'
)

# Create a new table
db.create_table('users', ['id', 'name', 'email'])

# Insert data
db.insert('users', {
    'id': '1',
    'name': 'John Doe',
    'email': 'john@example.com'
})

# Select data
all_users = db.select('users')
specific_columns = db.select('users', columns=['name', 'email'])

# Update data
db.update(
    'users',
    where={'id': '1'},
    values={'name': 'John Smith'}
)

# Delete data
db.delete('users', where={'id': '1'})
```

## API Reference

### GSheetsDB

#### `__init__(credentials_path: str, spreadsheet_id: str)`
Initialize the Google Sheets database connection.

#### `create_table(table_name: str, columns: List[str]) -> bool`
Create a new worksheet (table) in the spreadsheet.

#### `insert(table_name: str, data: Dict[str, Any]) -> bool`
Insert a new row into the specified table.

#### `select(table_name: str, columns: Optional[List[str]] = None) -> List[Dict[str, Any]]`
Select data from the specified table.

#### `update(table_name: str, where: Dict[str, Any], values: Dict[str, Any]) -> bool`
Update rows in the specified table that match the where condition.

#### `delete(table_name: str, where: Dict[str, Any]) -> bool`
Delete rows from the specified table that match the where condition.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

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