Skip to content

Commit b3b1c59

Browse files
CobaltCobalt
authored andcommitted
update README.md - Add Contributing
1 parent e4e4ee1 commit b3b1c59

File tree

1 file changed

+61
-8
lines changed

1 file changed

+61
-8
lines changed

README.md

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,66 @@
11
# gino-quart
22

3-
An extension for GINO to support Quart server.
3+
![test](https://github.com/python-gino/gino-quart/workflows/test/badge.svg)
44

5-
**This project "gino-quart" is currently not maintained and needs adoption.**
5+
## Introduction
66

7-
Since GINO 1.0, the built-in extensions are now separate projects supported by
8-
the community. This project is copied here directly from GINO 0.8.x for
9-
compatibility. Help is needed to:
7+
An extension for GINO to support [quart](https://gitlab.com/pgjones/quart) server.
108

11-
* Keep this project maintained - follow Quart releases, fix issues, etc.
12-
* Add more examples and documentation.
13-
* Answer questions in the community.
9+
## Usage
10+
11+
The common usage looks like this:
12+
13+
```python
14+
from quart import Quart
15+
from gino.ext.quart import Gino
16+
17+
app = Quart()
18+
db = Gino(app, **kwargs)
19+
```
20+
21+
## Configuration
22+
23+
GINO adds a `before_request`, `after_request` and `before_first_request` hook to the Quart app to setup and cleanup database according to
24+
the configurations that passed in the `kwargs` parameter.
25+
26+
The config includes:
27+
28+
| Name | Description | Default |
29+
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------- |
30+
| `driver` | the database driver | `asyncpg` |
31+
| `host` | database server host | `localhost` |
32+
| `port` | database server port | `5432` |
33+
| `user` | database server user | `postgres` |
34+
| `password` | database server password | empty |
35+
| `database` | database name | `postgres` |
36+
| `dsn` | a SQLAlchemy database URL to create the engine, its existence will replace all previous connect arguments. | N/A |
37+
| `retry_times` | the retry times when database failed to connect | `20` |
38+
| `retry_interval` | the interval in **seconds** between each time of retry | `5` |
39+
| `pool_min_size` | the initial number of connections of the db pool. | N/A |
40+
| `pool_max_size` | the maximum number of connections in the db pool. | N/A |
41+
| `echo` | enable SQLAlchemy echo mode. | N/A |
42+
| `ssl` | SSL context passed to `asyncpg.connect` | `None` |
43+
| `use_connection_for_request` | flag to set up lazy connection for requests. | N/A |
44+
| `retry_limit` | the number of retries to connect to the database on start up. | 1 |
45+
| `retry_interval` | seconds to wait between retries. | 1 |
46+
| `kwargs` | other parameters passed to the specified dialects, like `asyncpg`. Unrecognized parameters will cause exceptions. | N/A |
47+
48+
## Lazy Connection
49+
50+
If `use_connection_for_request` is set to be True, then a lazy connection is available
51+
at `request['connection']`. By default, a database connection is borrowed on the first
52+
query, shared in the same execution context, and returned to the pool on response.
53+
If you need to release the connection early in the middle to do some long-running tasks,
54+
you can simply do this:
55+
56+
```python
57+
await request['connection'].release(permanent=False)
58+
```
59+
60+
## Contributing
61+
62+
You're welcome to contribute to this project. It's really appreciated. Please [fork this project and create a pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) to the [dev branch](https://github.com/python-gino/gino-quart/tree/dev).
63+
64+
- Dependency management is done via [poetry](https://python-poetry.org/)
65+
- Pull request for new features _must_ include the appropriate tests integrated in `tests/test_gino_quart.py`
66+
- You should format your code. Recommended is [black](https://black.readthedocs.io/en/stable/)

0 commit comments

Comments
 (0)