DEV Community

aaronblondeau
aaronblondeau

Posted on

SurrealDB + Python

I've had my eye on SurrealDB for quite some time and finally got a chance to try it out. I did try some experiments with it a few months ago, but their documentation was so sparse I couldn't get it to go. Things are much better now and I feel like SurrealDB lives up to the hype.

I was especially interested to see how much of an application backend SurrealDB could cover.

Capability SurrealDB
User Authentication Yep, via JWT tokens too!
Permissions I used table PERMISSIONS - worked great and should allow for complex scenarios.
Multi-tenant data Yes via permissions. (Surreal also has namespaces)
File storage Ha - not really unless you store as string encoded data.
Background tasks Events + http functions could really help here to coordinate things like email delivery.

See my detailed Jupyter Notebook here : https://gist.github.com/aaronblondeau/deb7354105ed6a2daa07e49502324e5e

Things that I liked

  • The user auth model works great.
  • The query language is very intuitive. I especially liked the graph relationship query syntax.
  • LET statement is super handy.
  • The 3rd party Surrealist UI now works like a charm.
  • Being able to create tables (and relationships) on the fly is very handy for prototyping work.
  • Vectors (for embeddings) are built in.
  • Built in support for GeoJSON - sweet!

Things that I didn't like

  • No errors. A lot of things I tried just returned empty data. Maybe this is just the Python SDK, but it made it really hard to troubleshoot queries.
  • No graph search. I am working on a specific use case that requires graph route searching abilities and these don't appear to be available yet.
  • Events can be a bit hard to reason about as they occur after the update and data in the event payload may no longer exist. Maybe I should've been using functions instead.
  • No CASCADE delete (but I did accomplish what I wanted with events)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay