The SurrealDB SDK for Python lets you connect to SurrealDB from any Python application. It supports both synchronous and asynchronous workflows, connecting to remote instances over WebSocket or HTTP, and running embedded databases in-process. The SDK provides methods for querying, managing data and authentication, and subscribing to real-time updates with live queries.
The SDK requires Python 3.10 or later, and is available as a PyPI package.
The latest version of the SDK is 2.0.0.
The SDK works with SurrealDB versions v2.0.0 and later, including the current release, v3.2.4.
Getting started
Learn
Concepts
Connecting to SurrealDB - open a connection over HTTP or WebSocket
Authentication - sign up, sign in, and authenticate with a token
Multiple sessions - run isolated sessions over a single connection
Executing queries - send SurrealQL and read the results back
Data manipulation - create, select, update, upsert and delete records
Value types - how SurrealDB's types map onto native ones
Transactions - group statements so they succeed or fail together
Live queries - stream changes as they happen
Error handling - what a failure looks like, and how to catch it
Embedded databases - run SurrealDB in-process for tests and local use
Contributing
To contribute to the SDK code, submit an Issue or Pull Request in the surrealdb.py repository. To contribute to this documentation, submit an Issue or Pull Request in the docs.surrealdb.com repository.