Bookrest - The easiest way to add rest API to an arbitrary DB
Bookrest allows you to add an API (and browsable htmls) to arbitrary databases -- well almost arbitrary, the tables must have PKs. The databases do not need to be managed by Django.
Installation and usage
pip install bookrest
Then in your settings.py,
INSTALLED_APPS = [
# ...
"rest_framework",
"bookrest",
]
Add a key to your settings.DATABASES named bookrest, and point it to the DB you want to expose as an API. Keep your default db as is, you can use it for user management and other Django apps.
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
},
"bookrest": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "data/sample.sqlite3"),
},
}
Connect your urls to bookrest.urls
urlpatterns = [
# ...
path("api/", include("bookrest.urls"))
]
🚀 Boom! You are in business. All your tables will have a full read/write API
Todo
- Test with Sqlite
- Publish on Pypi
- Test with Postgres
- Test with Mysql
- Add setting to enable a read only API
- Enable circleci
- Silently drop tables with no PKs rather than failing (bad idea??)
Inspired by
This projects was inspired by datasette. I loved datasette, but because DRF has a geat browsable API and Django has powerful introspection capabilities, I wanted to do it in Django+DRF.
Bookrest gets all the power of DRF - browsable API, coreapi, filtering, pagination. Set a REST_FRAMEWORK setting in your settings.py and bookrest will apply it.
Whats with the name?
You can put the bookrest on table, and it makes reading simpler.
Metadata
Release files for bookrest 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bookrest-0.1.4.tar.gz | 4.4 kB | Without provenance | Details for bookrest-0.1.4.tar.gz |
Release files / bookrest-0.1.4.tar.gz
| Download URL | bookrest-0.1.4.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d72f8c959721e363b7d8e5b35825a06c70f309445c8da07efd90c21bf603563
|
|
BLAKE2b-256 checksum How to use checksums |
53617b6d3fcb44e4b161c6c06b0a1258cee4e9c84f84a380e3d8e2401ff98181
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for bookrest 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.