Skills surrealdb-python
🗄️

surrealdb-python

Safe ⚙️ External commands🌐 Network access📁 Filesystem access

Work with SurrealDB in Python

Building applications with SurrealDB requires understanding its multi-model capabilities including graph relationships, vector embeddings, and real-time subscriptions. This skill provides comprehensive guidance for using the Python SDK to implement CRUD operations, semantic search, and graph traversal patterns.

Supports: Claude Codex Code(CC)
📊 70 Adequate
1

Download the skill ZIP

2

Upload in Claude

Go to Settings → Capabilities → Skills → Upload skill

3

Toggle on and start using

Test it

Using "surrealdb-python". How do I create users and find friends of friends using graph traversal?

Expected outcome:

  • Create two users first:
  • await db.create('person:alice', {'name': 'Alice'})
  • await db.create('person:bob', {'name': 'Bob'})
  • Create a knows relationship between them:
  • await db.query("RELATE person:alice->knows->person:bob SET since = '2024-01-01'")
  • Find friends of friends using multi-hop traversal:
  • result = await db.query("SELECT ->knows->person->knows->person AS friends_of_friends FROM person:alice")

Using "surrealdb-python". How do I store document embeddings and search for similar content?

Expected outcome:

  • First define your schema:
  • await db.query("DEFINE TABLE documents SCHEMAFULL")
  • Generate and store embedding with your model:
  • embedding = model.encode(text).tolist()
  • await db.create('documents', {'content': text, 'embedding': embedding})
  • Search using KNN:
  • SELECT * FROM documents WHERE embedding <|5|> $query_vector

Using "surrealdb-python". Set up a real-time subscription to watch for changes

Expected outcome:

  • Start a live query on a table:
  • live_id = await db.live('user')
  • Subscribe to notifications:
  • async for notification in db.subscribe_live(live_id):
  • print(f"Change: {notification['action']} - {notification['result']}")
  • Stop when done:
  • await db.kill(live_id)

Security Audit

Safe
v5 • 1/16/2026

Documentation-only skill containing Markdown guides and Python code examples for SurrealDB operations. All 172 static findings are false positives: the analyzer misinterprets markdown backticks as shell execution, vector similarity functions as crypto algorithms, and database queries as reconnaissance. No executable code, no network calls, no file system access beyond documentation references.

4
Files scanned
1,266
Lines analyzed
3
findings
5
Total audits

Risk Factors

⚙️ External commands (120)
references/graph_operations.md:5 references/graph_operations.md:5 references/graph_operations.md:11-16 references/graph_operations.md:16-20 references/graph_operations.md:20-29 references/graph_operations.md:29-35 references/graph_operations.md:35-41 references/graph_operations.md:41-47 references/graph_operations.md:47-60 references/graph_operations.md:60-66 references/graph_operations.md:66-76 references/graph_operations.md:76-80 references/graph_operations.md:80-85 references/graph_operations.md:85-89 references/graph_operations.md:89-91 references/graph_operations.md:91-103 references/graph_operations.md:103-111 references/graph_operations.md:111-117 references/graph_operations.md:117-123 references/graph_operations.md:123-129 references/graph_operations.md:129-136 references/graph_operations.md:136-137 references/graph_operations.md:137-138 references/graph_operations.md:138-143 references/graph_operations.md:143-149 references/graph_operations.md:149-153 references/graph_operations.md:153-159 references/graph_operations.md:159-165 references/graph_operations.md:165-180 references/graph_operations.md:180-186 references/graph_operations.md:186-190 references/graph_operations.md:190-196 references/graph_operations.md:196-204 references/graph_operations.md:204-210 references/graph_operations.md:210-227 references/graph_operations.md:227-231 references/graph_operations.md:231-247 references/graph_operations.md:247-251 references/graph_operations.md:251-267 references/graph_operations.md:267-273 references/graph_operations.md:273-278 references/graph_operations.md:278-282 references/graph_operations.md:282-289 references/graph_operations.md:289-293 references/graph_operations.md:293-300 references/graph_operations.md:300-306 references/graph_operations.md:306 references/vector_search.md:15 references/vector_search.md:21-29 references/vector_search.md:29-33 references/vector_search.md:33-43 references/vector_search.md:43-49 references/vector_search.md:49-64 references/vector_search.md:64-68 references/vector_search.md:68-83 references/vector_search.md:83-87 references/vector_search.md:87-110 references/vector_search.md:110-116 references/vector_search.md:116-130 references/vector_search.md:130-134 references/vector_search.md:134-158 references/vector_search.md:158-162 references/vector_search.md:162-172 references/vector_search.md:172-176 references/vector_search.md:176-246 references/vector_search.md:246-252 references/vector_search.md:252-257 references/vector_search.md:257-263 references/vector_search.md:263-285 references/vector_search.md:285-289 references/vector_search.md:289-314 references/vector_search.md:314-320 references/vector_search.md:320-345 references/vector_search.md:345-350 references/vector_search.md:350-351 references/vector_search.md:351-352 references/vector_search.md:352-378 references/vector_search.md:378-401 references/vector_search.md:401-405 references/vector_search.md:405-432 SKILL.md:27-34 SKILL.md:34-50 SKILL.md:50-66 SKILL.md:66-73 SKILL.md:73-83 SKILL.md:83-86 SKILL.md:86-104 SKILL.md:104-108 SKILL.md:108 SKILL.md:108-109 SKILL.md:109-113 SKILL.md:113-120 SKILL.md:120-134 SKILL.md:134-137 SKILL.md:137-150 SKILL.md:150-153 SKILL.md:153-158 SKILL.md:158-164 SKILL.md:164-176 SKILL.md:176-183 SKILL.md:183-190 SKILL.md:190-193 SKILL.md:193-201 SKILL.md:201-204 SKILL.md:204-213 SKILL.md:213-220 SKILL.md:220-223 SKILL.md:223-226 SKILL.md:226-231 SKILL.md:231-234 SKILL.md:234-240 SKILL.md:240-246 SKILL.md:246-259 SKILL.md:259-264 SKILL.md:264-265 SKILL.md:265-269 SKILL.md:269-275 SKILL.md:275-276 SKILL.md:276-313 SKILL.md:313-314
🌐 Network access (5)
📁 Filesystem access (1)
Audited by: claude View Audit History →

Quality Score

41
Architecture
100
Maintainability
87
Content
21
Community
100
Security
91
Spec Compliance

What You Can Build

Build RAG Applications

Store document embeddings and retrieve relevant context for language model generation using semantic similarity search.

Implement Knowledge Graphs

Model complex entity relationships with typed edges and metadata for sophisticated graph traversal queries.

Create Real-Time Apps

Subscribe to live data changes for dashboards, chat applications, or notification systems with automatic updates.

Try These Prompts

Basic Connection
Show me how to connect to SurrealDB using the Python async SDK with authentication and select a namespace and database.
Graph Operations
Help me create a RELATE statement in SurrealDB to connect two entities with metadata, and then show how to traverse the relationship.
Vector Search
Write a SurrealQL query using the KNN operator to find the 5 most similar documents based on cosine similarity with a query embedding.
Real-Time Subscriptions
Show me how to subscribe to live changes on a SurrealDB table and handle CREATE, UPDATE, and DELETE notifications.

Best Practices

  • Use context managers (async with) for automatic connection cleanup and proper resource management.
  • Parameterize queries with named parameters ($variable) to prevent injection attacks.
  • Add timeouts to recursive graph queries and create indexes on frequently accessed fields for performance.

Avoid

  • Avoid hardcoding credentials in source code; use environment variables instead.
  • Do not skip schema definitions when data integrity is important; use SCHEMAFULL tables.
  • Avoid unlimited recursive traversal without depth limits or timeouts, which can cause performance issues.

Frequently Asked Questions

What Python version is required?
SurrealDB Python SDK requires Python 3.8 or higher with asyncio support for async operations.
What embedding models work with SurrealDB?
Any embedding model can be used including Sentence Transformers, OpenAI embeddings, and HuggingFace models. Vectors are stored as arrays.
How do I integrate with LangChain?
Use SurrealDBStore from langchain_community.vectorstores for direct LangChain integration with similarity search.
Is my data safe with vector search?
Vectors are stored in your SurrealDB database. No data is sent to external services unless you use cloud embedding APIs.
Why are my queries slow?
Add indexes on vector fields and frequently queried metadata. Use appropriate K values and add timeouts to complex queries.
How does this compare to Neo4j?
SurrealDB combines document, graph, and vector storage in one database, simplifying architecture for AI applications.