Skip to main content

Django PostgreSQL backend proxied over WebSockets (for WASM)

Project description

django-postgresql-ws

django-postgresql-ws is an alternative PostgreSQL backend for Django proxied over WebSockets. It will only work when configured to run against a WebSockets proxy that is then communicating with the PostgreSQL server. websockify is the standard WebSockets proxy service it is tested against.

The purpose of this backend is to allow a Django application to run against a PostgreSQL server in a WebAssembly (Pyodide) environment, where native sockets are not allowed but WebSockets are. The WebSocket communication is handled by the pgwasm library, which itself switches between using a the native websockets libray when being run in a native environment, and using the JS-proxied interface when run under Pyodide.

This backend is based on a copy of the PostgreSQL backend that ships with Django 4.1 with updates made to use pgwasm instead of psycopg2. Note that while Django does not natively support async in its implementation of its ORM, the database backend needs to be async in order to communicate over WebSockets in Pyodide, since the JS interface receives WebSockets messages via callbacks. The async_to_sync method provided by asgiref properly handle running the async methods in the proper event loop.

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

django_postgresql_ws-0.1.0.tar.gz (19.2 kB view hashes)

Uploaded Source

Built Distribution

django_postgresql_ws-0.1.0-py3-none-any.whl (21.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page