Skip to content

Python

Python SDK

The SurrealDB SDK for Python lets you connect to SurrealDB from any Python application. It has a blocking client and an asyncio client, connects to a remote instance over WebSocket or HTTP, and can run an embedded database in the same process. Use it to run SurrealQL queries, read and write records, manage authentication and sessions, and receive changes as they happen with live queries.

Important

The SDK requires Python 3.10 or later, and is available as a PyPI package.

Note

The latest version of the SDK is 3.0.0. It works with SurrealDB 2.x, 3.x and 4.x, and refuses other versions when it connects. The current SurrealDB release is v4.0.0.

If you are upgrading a project from version 2 of the SDK, read Migrating to Python SDK 3.x first. Version 3 changes what several common calls return, and version 2 cannot write datetimes to SurrealDB 4.0.

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.

Was this page helpful?