Skip to main content

The official SurrealDB library for Python.

Project description

SurrealDB Icon


SurrealDB Logo SurrealDB Logo

SurrealDB SurrealDB is the ultimate cloud
database for tomorrow's applications

Develop easier.   Build faster.   Scale quicker.


         

Blog   Github	  LinkedIn   Twitter   Youtube   Dev   Discord   StackOverflow

surrealdb.py

The official SurrealDB library for Python.

See the documentation here

Getting Started

First install SurrealDB if you haven't already.

Install the python library

pip install surrealdb

Alternatively, you can use install it using Poetry

from surrealdb import Surreal

async def main():
    """Example of how to use the SurrealDB client."""
    async with Surreal("ws://localhost:8000/rpc") as db:
        await db.signin({"user": "root", "pass": "root"})
        await db.use("test", "test")
        await db.create(
            "person",
            {
                "user": "me",
                "pass": "safe",
                "marketing": True,
                "tags": ["python", "documentation"],
            },
        )
        print(await db.select("person"))
        print(await db.update("person", {
            "user":"you",
            "pass":"very_safe",
            "marketing": False,
            "tags": ["Awesome"]
        }))
        print(await db.delete("person"))

        # You can also use the query method 
        # doing all of the above and more in SurrealQl
        
        # In SurrealQL you can do a direct insert 
        # and the table will be created if it doesn't exist
        await db.query("""
        insert into person {
            user: 'me',
            pass: 'very_safe',
            tags: ['python', 'documentation']
        };
        
        """)
        print(await db.query("select * from person"))
        
        print(await db.query("""
        update person content {
            user: 'you',
            pass: 'more_safe',
            tags: ['awesome']
        };
        
        """))
        print(await db.query("delete person"))

if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

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

surrealdb-0.3.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

surrealdb-0.3.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file surrealdb-0.3.1.tar.gz.

File metadata

  • Download URL: surrealdb-0.3.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.3.0

File hashes

Hashes for surrealdb-0.3.1.tar.gz
Algorithm Hash digest
SHA256 3c8a458de38e3c6314b4472c4353cfc5b65077073a723942a4a90114b872376e
MD5 f679df0ef57938065e8d13bd32aee3e4
BLAKE2b-256 7ee0550b6815fd5dbfce557c4d92431395ed795eda533556cd161371e383835a

See more details on using hashes here.

File details

Details for the file surrealdb-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: surrealdb-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.3.0

File hashes

Hashes for surrealdb-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 633269a7064067d264ac1c429386e12a399e344bd74917dfa471318e1dc8995a
MD5 0a36c30fe04a3b728c6bc7e8b65c4897
BLAKE2b-256 08b0634f23ba18b2043a70855a398dee7553e55436e7816e023045c95a7e0c64

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