Skip to main content

LayData Python client SDK

Project description

LayData Python Client SDK

🚀 An async Python SDK for interacting with LayData — an API-first database platform similar to Airtable, but built for developer speed and flexibility.

📦 Installation

pip install laydata

⚡ Quickstart

A minimal example showing the full high-level flow: connect, navigate the structure, work with records, and close the session.

import asyncio from laydata import Data

async def main(): # 1. Connect to LayData data = Data(endpoint="http://127.0.0.1:8077")

# 2. Navigate the structure (use PascalCase!)
MyCompany = await data.space("MyCompany")
SalesCRM = await MyCompany.base("SalesCRM")
Customers = await SalesCRM.table("Customers")

# 3. Work with records
NewCustomer = await Customers.add({
    "CustomerName": "Alice",
    "Email": "alice@example.com",
    "IsActive": True
})

AllCustomers = await Customers.records(take=10)
await Customers.delete_record(NewCustomer["id"])

# 4. Close the connection
await data.close()

asyncio.run(main())

💡 Tip: Always use PascalCase for Space, Base, Table, and field names. It keeps your data model clean, predictable, and less error-prone.

🧠 Core Concepts

LayData organizes your data in a simple hierarchy:

Space → Base → Table → Record

Entity Example Description Space MyCompany Top-level workspace (e.g. a company or project) Base SalesCRM A database within a Space Table Customers A table containing records Record Customer A single row inside a table

📌 All operations are async and follow the same pattern: space → base → table → record

🪄 Common Workflows

✏️ Create and Update Records

Create a new record

Customer = await Customers.add({ "CustomerName": "Alice", "Email": "alice@example.com" })

Find a record and edit it

PlumberJob = await Jobs.get_by("JobName", "Plumber") await PlumberJob.edit({"JobName": "Plumba"})

Get a specific field value

salary = PlumberJob.field("Salary") print(salary)

🔍 Query and Filter Data

Simple filtering

HighValueCustomers = await Customers.where("Value", ">=", 10000).all()

Get the top record

TopCustomer = await Customers.desc("Value").first()

Find by field

SpecificCustomer = await Customers.get_by("Email", "alice@example.com")

🔗 Chained Queries

TopElectronics = await ( Products .contains("Category", "Electronics") .gte("Price", 200) .is_not_empty("Description") .desc("Price") .take(10) .all() )

⚙️ Configuration

Create a .env file:

LAYDATA_BASE_URL=http://127.0.0.1:8077 LAYDATA_ALLOW_ATTACHMENTS=1 # for local development only

Load it automatically:

from dotenv import load_dotenv load_dotenv()

data = Data() # uses LAYDATA_BASE_URL from .env

🧰 Requirements • Python >= 3.10 • httpx – async HTTP client • python-dotenv (optional)

🧪 Advanced Usage

💡 These features are powerful but not essential for getting started.

📁 Special Field Types

from laydata import SingleSelect, MultiSelect, Date, Attachment from datetime import datetime

Employee = await Employees.add({ "Department": SingleSelect("Engineering"), "Skills": MultiSelect(["Python", "React"]), "HireDate": Date(datetime(2023, 1, 15)), "ProfilePhoto": Attachment("https://example.com/photo.jpg") })

🛠 Table Metadata Management

Tasks = await ProjectBase.table("Tasks", icon="📋", description="Task tracking") await Tasks.update_icon("✅") await Tasks.update_description("Updated description")

AllTables = await ProjectBase.tables()

📦 Batch Operations & Error Handling

BatchData = [{"Name": f"Item {i}", "Price": 10 + i} for i in range(10)]

for item in BatchData: try: await Items.add(item) except Exception as e: print(f"Failed: {e}")

💡 Best Practices

✅ Always use PascalCase for Space, Base, Table, and field names. ✅ Treat records as objects — record.edit() and record.field() are the preferred ways to work with them. ✅ Start with simple queries (where().all(), get_by()) and build up to more complex filters as needed. ✅ Keep risky or infrequent operations (bulk deletes, update_icon) in dedicated functions or scripts.

📚 Next Steps • 📘 Explore Advanced Usage • 🛠 Use LayData as a backend for admin panels, CRMs, or internal tools • 🌐 Watch for new releases on GitHub

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

laydata-0.1.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

laydata-0.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file laydata-0.1.1.tar.gz.

File metadata

  • Download URL: laydata-0.1.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for laydata-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f75192eff66a697b3ff1adc108d164058e49cafddbaa8ba82fe7e38ea07d0fe4
MD5 f2ab2501e8e71ec9d82956a57410ddf0
BLAKE2b-256 ac5b03f8dfe2a7938686fdc08534c35f36fdd9b202f145a9993a18b8b012e9b2

See more details on using hashes here.

File details

Details for the file laydata-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: laydata-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for laydata-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25b9f7a30fd20ad22223294de2eb4b1484380dc93248cb2e70a77b84c87e5c84
MD5 bd10aff76cd6beb9a7af6c175cc2fd59
BLAKE2b-256 0e349d256c4f5d075eac6e4bab4c5af91b9ca104251201bd6fa48c4e1efba65c

See more details on using hashes here.

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