Abstract
SurrealDB is a scalable, distributed, collaborative, document-graph database, for the real-time web. It combines the database layer, the querying layer, and the API and authentication layer into one platform. It supports SQL querying from client devices, GraphQL, ACID transactions, WebSocket connections, structured and unstructured data, graph querying, full-text indexing, geospatial querying, and row-by-row permissions-based access.
The goal of this project is to add SurrealDB as a backend option for Django applications. This will allow Django developers to leverage the features and benefits of SurrealDB without having to write custom code or use third-party libraries. The project will involve implementing a database wrapper for SurrealDB that conforms to the Django database API.
Detailed design
The project will consist of the following components:
-
A database wrapper for SurrealDB that implements the required methods and attributes of the
django.db.backends.base.BaseDatabaseWrapper
class. The wrapper will use SurrealDB’s Python client library to communicate with the database server via WebSocket or HTTP. The wrapper will also handle schema creation and migration using SurrealDB’s SQL support. -
A database introspection module for SurrealDB that implements the required methods and attributes of the
django.db.backends.base.BaseDatabaseIntrospection
class. The module will use SurrealDB’s SQL support to query the database metadata and provide information about the tables, columns, indexes, constraints, etc. -
A database creation module for SurrealDB that implements the required methods and attributes of the
django.db.backends.base.BaseDatabaseCreation
class. The module will use SurrealDB’s SQL support to create and destroy test databases for running Django’s test suite. -
A database client module for SurrealDB that implements the required methods and attributes of the
django.db.backends.base.BaseDatabaseClient
class. The module will provide a command-line interface for executing SQL statements directly on the database server using SurrealDB’s CLI tool. -
A database-features module for SurrealDB that implements the required methods and attributes of the
django.db.backends.base.BaseDatabaseFeatures
class. The module will indicate which features are supported or not supported by SurrealDB, such as transactions, foreign keys, savepoints, etc. -
A database operations module for SurrealDB that implements the required methods and attributes of the
django.db.backends.base.BaseDatabaseOperations
class. The module will provide various database-specific operations, such as quoting column names, converting values to database types, escaping wildcards, etc. -
A database schema editor module for SurrealDB that implements the required methods and attributes of the
django.db.backends.base.BaseDatabaseSchemaEditor
class. The module will provide methods for creating, altering, and deleting tables, columns, indexes, constraints, etc. using SurrealDB’s SQL support. -
A settings module that defines the configuration options for using SurrealDB as a backend for Django applications. The module will include options such as database name, host, port, username, password, SSL certificate, etc.