Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 002e579

Browse files
committed
update docs
1 parent 6e36535 commit 002e579

File tree

5 files changed

+103
-4
lines changed

5 files changed

+103
-4
lines changed

docs/contributing.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Contibuting
2+
3+
All contributions to *databases* are welcomed!
4+
5+
## Issues
6+
7+
To make it as simple as possible for us to help you, please include the following:
8+
9+
* OS
10+
* python version
11+
* databases version
12+
* database backend (mysql, sqlite or postgresql)
13+
* database driver (aiopg, aiomysql etc.)
14+
15+
Please try to always include the above unless you're unable to install *databases* or **know** it's not relevant
16+
to your question or feature request.
17+
18+
## Pull Requests
19+
20+
It should be quite straight forward to get started and create a Pull Request.
21+
22+
!!! note
23+
Unless your change is trivial (typo, docs tweak etc.), please create an issue to discuss the change before
24+
creating a pull request.
25+
26+
To make contributing as easy and fast as possible, you'll want to run tests and linting locally.
27+
28+
You'll need to have **python >= 3.6 (recommended 3.7+)** and **git** installed.
29+
30+
## Getting started
31+
32+
1. Clone your fork and cd into the repo directory
33+
```bash
34+
git clone [email protected]:<your username>/databases.git
35+
cd databases
36+
```
37+
38+
2. Create and activate virtual env
39+
```bash
40+
virtualenv -p `which python3.6` env
41+
source env/bin/activate
42+
```
43+
44+
3. Install databases, dependencies and test dependencies
45+
```bash
46+
pip install -r requirements.txt
47+
```
48+
49+
4. Checkout a new branch and make your changes
50+
```bash
51+
git checkout -b my-new-feature-branch
52+
```
53+
54+
## Make your changes...
55+
56+
## Contribute
57+
58+
1. Formatting and linting - databases uses black for formatting, autoflake for linting and mypy for type hints check
59+
run all of those with lint script
60+
```bash
61+
./scripts/lint
62+
```
63+
64+
2. Prepare tests (basic)
65+
1. Set-up `TEST_DATABASE_URLS` env variable where you can comma separate urls for several backends
66+
2. The simples one is for sqlite alone: `sqlite:///test.db`
67+
68+
3. Prepare tests (all backends)
69+
1. In order to run all backends you need a docker instalation on your system [from here](https://docs.docker.com/get-docker/)
70+
2. You need to set-up `TEST_IN_DOCKER` env variable (to any non-null value `YES` or `1`)
71+
72+
4. Run tests
73+
```bash
74+
./scripts/test
75+
```
76+
77+
5. Build documentation
78+
1. If you have changed the documentation make sure it runs successfully
79+
```bash
80+
./scripts/test
81+
```
82+
83+
6. Commit, push, and create your pull request

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ nav:
1313
- Database Queries: 'database_queries.md'
1414
- Connections & Transactions: 'connections_and_transactions.md'
1515
- Tests & Migrations: 'tests_and_migrations.md'
16+
- Contributing: 'contributing.md'
1617

1718
markdown_extensions:
1819
- mkautodoc

scripts/docs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
#!/bin/sh -e
22

33
export PREFIX=""
4-
if [ -d 'venv' ] ; then
4+
UNAME=$(uname)
5+
case "$UNAME" in
6+
"Linux") export SYSTEM="Linux" ;;
7+
"Darwin") export SYSTEM="Linux" ;;
8+
CYGWIN*) export SYSTEM="Windows" ;;
9+
MINGW*) export SYSTEM="Windows" ;;
10+
*) export SYSTEM="Linux" ;;
11+
esac
12+
13+
if [ -d 'venv' ]; then
14+
if [ $SYSTEM = "Linux" ] ; then
515
export PREFIX="venv/bin/"
16+
else
17+
export PREFIX="venv/Scripts/"
18+
fi
619
fi
720

821
set -x

scripts/test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ if [ -d 'venv' ]; then
1818
fi
1919
fi
2020

21-
if [ -z "$TEST_DATABASE_URLS" ]; then
22-
echo "Variable TEST_DATABASE_URLS must be set."
21+
if [ -z "$TEST_DATABASE_URLS" ] && [ -z "${TEST_IN_DOCKER+x}" ]; then
22+
echo "Variable TEST_DATABASE_URLS or TEST_IN_DOCKER must be set."
2323
exit 1
2424
fi
2525

tests/test_databases.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
from databases import Database, DatabaseURL
1414

15-
if sys.version_info >= (3, 8) and sys.platform.lower().startswith("win"):
15+
if sys.version_info >= (3, 8) and sys.platform.lower().startswith(
16+
"win"
17+
): # pragma: no cover
1618
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
1719

1820
assert "TEST_DATABASE_URLS" in os.environ, "TEST_DATABASE_URLS is not set."

0 commit comments

Comments
 (0)