Skip to main content

A Python client for Mathesar API

Project description

Mathesar Python Client

A typed, ergonomic Python client for the Mathesar JSON-RPC API.

  • Transport: JSON-RPC over HTTP
  • Auth: Basic auth (username/password)
  • Python: 3.13+
  • Dependencies: pydantic v2, requests

Quick start

from mathesar_client import MathesarClient

# Configure base URL and credentials via env or initialize the raw client accordingly
client = MathesarClient()  # uses defaults from MathesarClientRaw()

# Work with a database
db = client.database(database_id=1)

# Schemas
schemas = db.list_schemas()
public = db.schema_by_name("public")

# Tables
users = public.table_by_name("users")

# Records: returns column names and inlines linked summaries
page = users.records_list(limit=10, order_by=[("id", "asc")])
for row in page.results:
    print(row)

# Add a record using column names
new_row = users.record_add({
    "email": "jane@example.com",
    "full_name": "Jane Doe",
})

# Columns: create a UUID primary key
users.add_primary_key_column(pkey_type="UUIDv4", name="id")

# Constraints: add a unique constraint on email
users.add_unique_constraint(columns=["email"], name="uq_users_email")

# Data modeling: suggest types for a table
suggested = users.suggest_types()
print(suggested)

Package layout

  • mathesar_client.client_raw_models: Pydantic models for all API entities
  • mathesar_client.client_raw: Low-level raw client mapping API methods 1:1
  • mathesar_client.client: High-level client with Database → Schema → Table hierarchy and QoL

Notes

  • The high-level client resolves column names↔attnums automatically where relevant.
  • Record lists are enriched with column names and inline linked summaries when requested.
  • For foreign keys, referent table column identifiers are passed as-is; if you prefer names, resolve them with that table's column cache.

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

mathesar_client-0.1.0.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

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

mathesar_client-0.1.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file mathesar_client-0.1.0.tar.gz.

File metadata

  • Download URL: mathesar_client-0.1.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mathesar_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 03d8dd068f1a75a66986417b16208289f89e52f00260c36b33cff94c2b9e7602
MD5 633095fb3ca665c6cc2f121874d5d9bb
BLAKE2b-256 ed17cd9671fd2ca7941588479679d8296aead1b1928619d74a651b795c5e26b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for mathesar_client-0.1.0.tar.gz:

Publisher: pypi-deploy.yml on esoadamo/mathesar-client

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

File details

Details for the file mathesar_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mathesar_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d93d38ccd56e6543b48e23890dabcaea55e5eb5245b8b0c3e7adee7baee1c38d
MD5 50ab9055645fdae4e5949f447e068655
BLAKE2b-256 8788efc44e3a9c50f1ab785b694f090a29e2e7cb81e72d1590e38e3e26f140a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mathesar_client-0.1.0-py3-none-any.whl:

Publisher: pypi-deploy.yml on esoadamo/mathesar-client

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