Skip to content

Commit 787f4c4

Browse files
committed
Basic DB alias instructions, refs #6, #16
1 parent df9c87e commit 787f4c4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,24 @@ Install this library using `pip`:
3737

3838
## Usage
3939

40-
Add `"django_sql_dashboard"` to your `INSTALLED_APPS`.
40+
Add `"django_sql_dashboard"` to your `INSTALLED_APPS` in `settings.py`.
41+
42+
Define a `"dashboard"` database alias in `settings.py`. It should look something like this:
43+
44+
```python
45+
DATABASES = {
46+
"default": {
47+
"ENGINE": "django.db.backends.postgresql_psycopg2",
48+
"NAME": "mydb",
49+
},
50+
"dashboard": {
51+
"ENGINE": "django.db.backends.postgresql_psycopg2",
52+
"NAME": "mydb",
53+
"OPTIONS": {"options": "-c default_transaction_read_only=on -c statement_timeout=100"},
54+
},
55+
}
56+
```
57+
Even better: create a new PostgreSQL role that is limited to read-only SELECT access to a list of tables, following [these instructions](https://til.simonwillison.net/postgresql/read-only-postgresql-user).
4158

4259
Add the following to your `urls.py`:
4360

0 commit comments

Comments
 (0)