Sheet2DB Python SDK
Easily connect your Google Sheets to Python applications using the Sheet2DB API. This SDK provides convenient methods for reading, writing, and managing spreadsheet data through simple API calls.
🚀 Installation
pip install sheet2db-sdk
🛠 Usage
from sheet2db_client import Sheet2DBClient
client = Sheet2DBClient(api_id="your-api-id")
# Read data
result = client.read({
"limit": 5,
"format": "rows"
}, sheet="Customers")
print(result)
🔐 Authentication
You can pass tokens using the constructor or use helper methods:
client = Sheet2DBClient(api_id="your-api-id")
# Option 1: Basic Auth
client.use_basic_auth("username", "password")
# Option 2: JWT
client.use_jwt("your.jwt.token")
# Option 3: Bearer Token
client.use_bearer_token("secret-token")
📘 API Methods
read(options: dict, sheet: str) -> list
Reads rows from a sheet.
client.read({
"limit": 10,
"sortColumn":"Age",
"sortDirection": "desc"
}, sheet="Orders")
insert(data: List[dict], sheet: str) -> dict
Insert new rows.
client.insert([{"name": "Alice", "email": "[email protected]"}], sheet="Users")
update(options: dict, sheet: str) -> dict
Update rows either by row
or using a filter
.
# By row
client.update({
"type": "row",
"row": 3,
"data": {"status": "paid"}
}, sheet="Invoices")
# By filter
client.update({
"type": "filter",
"filter": "status=unpaid",
"data": {"status": "paid"}
}, sheet="Invoices")
delete(options: dict, sheet: str) -> dict
Delete a row or use filter.
client.delete({"type": "row", "row": 5}, sheet="Invoices")
client.delete({"type": "filter", "filter": "status:eq:cancelled"}, sheet="Invoices")
add_sheet(name: str, first_row: List[str], copy_columns_from: Optional[str] = None) -> dict
Create a new sheet.
client.add_sheet(
name="NewCustomers",
firstRow=["Name", "Email"]
)
delete_sheet(sheet: str) -> dict
Delete a sheet.
client.delete_sheet("OldSheet")