Skip to main content

Code-first database toolkit for SurrealDB - schema definitions, migrations, query building, and typed CRUD.

Project description

surql

License Python Version SurrealDB

A code-first database toolkit for SurrealDB. Define schemas, generate migrations, build queries, and perform typed CRUD -- all from Python.

Features

  • Code-First Migrations - Schema changes defined in code with automatic migration generation
  • Type-Safe Query Builder - Composable queries with Pydantic model integration
  • Vector Search - HNSW and MTREE index support with 8 distance metrics and EFC/M tuning
  • Graph Traversal - Native SurrealDB graph features with edge relationships
  • Query Caching - Memory and Redis-backed caching with @cache_query decorator
  • Live Queries - Real-time change notifications and streaming
  • Schema Visualization - Mermaid, GraphViz, and ASCII diagrams
  • CLI Tools - Migrations, schema inspection, validation, and database management
  • Async-First - Built with async/await, connection pooling, and retry logic

Quick Start

pip install oneiriq-surql

# or with uv
uv add oneiriq-surql
from surql.schema.fields import string_field, int_field, datetime_field
from surql.schema.table import table_schema, unique_index, TableMode

user_schema = table_schema(
  'user',
  mode=TableMode.SCHEMAFULL,
  fields=[
    string_field('name'),
    string_field('email', assertion='string::is::email($value)'),
    int_field('age', assertion='$value >= 0 AND $value <= 150'),
    datetime_field('created_at', default='time::now()', readonly=True),
  ],
  indexes=[unique_index('email_idx', ['email'])],
)
surql migrate create "Add user table"
surql migrate up
surql migrate status

Documentation

Full documentation at oneiriq.github.io/surql-py.

Requirements

  • Python 3.12+
  • SurrealDB 1.0+

License

Apache License 2.0 - see LICENSE.

TypeScript / Deno / Node.js

Looking for SurrealDB tooling in TypeScript? Check out surql -- a type-safe query builder and client for SurrealDB available on JSR and NPM.

Support

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

oneiriq_surql-1.3.0.tar.gz (540.4 kB view details)

Uploaded Source

Built Distribution

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

oneiriq_surql-1.3.0-py3-none-any.whl (211.8 kB view details)

Uploaded Python 3

File details

Details for the file oneiriq_surql-1.3.0.tar.gz.

File metadata

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

File hashes

Hashes for oneiriq_surql-1.3.0.tar.gz
Algorithm Hash digest
SHA256 7728f0bf5f181afa00a1269bf783d75e0fe6f0304716aa6cd4c778aa6251d62f
MD5 19faa6d806997a8839446ac9c60b2ffa
BLAKE2b-256 b15f736dd09afc017f1dcfb10584c237184d1495d2bc76d29d612695d6a99afd

See more details on using hashes here.

Provenance

The following attestation bundles were made for oneiriq_surql-1.3.0.tar.gz:

Publisher: publish.yml on Oneiriq/surql-py

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

File details

Details for the file oneiriq_surql-1.3.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for oneiriq_surql-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c597a34dd8569803f6e3bef59be04c0d5c99fbc9cdfb5dfb5a601d07be3af76c
MD5 eb2334025896e1629e8ebad726d98f0f
BLAKE2b-256 9cd719527bc8a841a6bedfbd8c5eda4413e52744dec6b5073a2d799676ed334f

See more details on using hashes here.

Provenance

The following attestation bundles were made for oneiriq_surql-1.3.0-py3-none-any.whl:

Publisher: publish.yml on Oneiriq/surql-py

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