gino-starlette


Namegino-starlette JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/python-gino/gino-starlette
SummaryAn extension for GINO to integrate with Starlette
upload_time2023-01-15 02:58:47
maintainerAobo Shi
docs_urlNone
authorTony Wang
requires_python>=3.6.2,<4.0
licenseBSD-3-Clause
keywords sqlalchemy python3 starlette gino
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # gino-starlette

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0bec53f18d3b49aea6f558a269df318a)](https://app.codacy.com/gh/python-gino/gino-starlette?utm_source=github.com&utm_medium=referral&utm_content=python-gino/gino-starlette&utm_campaign=Badge_Grade_Settings)

## Introduction

An extension for GINO to support starlette server.

## Usage

The common usage looks like this:

```python
from starlette.applications import Starlette
from gino.ext.starlette import Gino

app = Starlette()
db = Gino(app, **kwargs)
```

## Configuration

GINO adds a middleware to the Starlette app to setup and cleanup database according to
the configurations that passed in the `kwargs` parameter.

The config includes:

| Name                         | Description                                                                                                       | Default     |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------- |
| `driver`                     | the database driver                                                                                               | `asyncpg`   |
| `host`                       | database server host                                                                                              | `localhost` |
| `port`                       | database server port                                                                                              | `5432`      |
| `user`                       | database server user                                                                                              | `postgres`  |
| `password`                   | database server password                                                                                          | empty       |
| `database`                   | database name                                                                                                     | `postgres`  |
| `dsn`                        | a SQLAlchemy database URL to create the engine, its existence will replace all previous connect arguments.        | N/A         |
| `retry_times`                | the retry times when database failed to connect                                                                   | `20`        |
| `retry_interval`             | the interval in **seconds** between each time of retry                                                            | `5`         |
| `pool_min_size`              | the initial number of connections of the db pool.                                                                 | N/A         |
| `pool_max_size`              | the maximum number of connections in the db pool.                                                                 | N/A         |
| `echo`                       | enable SQLAlchemy echo mode.                                                                                      | N/A         |
| `ssl`                        | SSL context passed to `asyncpg.connect`                                                                           | `None`      |
| `use_connection_for_request` | flag to set up lazy connection for requests.                                                                      | N/A         |
| `retry_limit`                | the number of retries to connect to the database on start up.                                                     | 1           |
| `retry_interval`             | seconds to wait between retries.                                                                                  | 1           |
| `kwargs`                     | other parameters passed to the specified dialects, like `asyncpg`. Unrecognized parameters will cause exceptions. | N/A         |

## Lazy Connection

If `use_connection_for_request` is set to be True, then a lazy connection is available
at `request['connection']`. By default, a database connection is borrowed on the first
query, shared in the same execution context, and returned to the pool on response.
If you need to release the connection early in the middle to do some long-running tasks,
you can simply do this:

```python
await request['connection'].release(permanent=False)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/python-gino/gino-starlette",
    "name": "gino-starlette",
    "maintainer": "Aobo Shi",
    "docs_url": null,
    "requires_python": ">=3.6.2,<4.0",
    "maintainer_email": "shiaobo8@gmail.com",
    "keywords": "sqlalchemy,python3,starlette,gino",
    "author": "Tony Wang",
    "author_email": "wwwjfy@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8e/fb/e60d828ec11c1ccd859708d1a32f1cfc1deef0f1a169a3ad3eb9c53b4937/gino_starlette-0.1.6.tar.gz",
    "platform": null,
    "description": "# gino-starlette\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0bec53f18d3b49aea6f558a269df318a)](https://app.codacy.com/gh/python-gino/gino-starlette?utm_source=github.com&utm_medium=referral&utm_content=python-gino/gino-starlette&utm_campaign=Badge_Grade_Settings)\n\n## Introduction\n\nAn extension for GINO to support starlette server.\n\n## Usage\n\nThe common usage looks like this:\n\n```python\nfrom starlette.applications import Starlette\nfrom gino.ext.starlette import Gino\n\napp = Starlette()\ndb = Gino(app, **kwargs)\n```\n\n## Configuration\n\nGINO adds a middleware to the Starlette app to setup and cleanup database according to\nthe configurations that passed in the `kwargs` parameter.\n\nThe config includes:\n\n| Name                         | Description                                                                                                       | Default     |\n| ---------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------- |\n| `driver`                     | the database driver                                                                                               | `asyncpg`   |\n| `host`                       | database server host                                                                                              | `localhost` |\n| `port`                       | database server port                                                                                              | `5432`      |\n| `user`                       | database server user                                                                                              | `postgres`  |\n| `password`                   | database server password                                                                                          | empty       |\n| `database`                   | database name                                                                                                     | `postgres`  |\n| `dsn`                        | a SQLAlchemy database URL to create the engine, its existence will replace all previous connect arguments.        | N/A         |\n| `retry_times`                | the retry times when database failed to connect                                                                   | `20`        |\n| `retry_interval`             | the interval in **seconds** between each time of retry                                                            | `5`         |\n| `pool_min_size`              | the initial number of connections of the db pool.                                                                 | N/A         |\n| `pool_max_size`              | the maximum number of connections in the db pool.                                                                 | N/A         |\n| `echo`                       | enable SQLAlchemy echo mode.                                                                                      | N/A         |\n| `ssl`                        | SSL context passed to `asyncpg.connect`                                                                           | `None`      |\n| `use_connection_for_request` | flag to set up lazy connection for requests.                                                                      | N/A         |\n| `retry_limit`                | the number of retries to connect to the database on start up.                                                     | 1           |\n| `retry_interval`             | seconds to wait between retries.                                                                                  | 1           |\n| `kwargs`                     | other parameters passed to the specified dialects, like `asyncpg`. Unrecognized parameters will cause exceptions. | N/A         |\n\n## Lazy Connection\n\nIf `use_connection_for_request` is set to be True, then a lazy connection is available\nat `request['connection']`. By default, a database connection is borrowed on the first\nquery, shared in the same execution context, and returned to the pool on response.\nIf you need to release the connection early in the middle to do some long-running tasks,\nyou can simply do this:\n\n```python\nawait request['connection'].release(permanent=False)\n```\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "An extension for GINO to integrate with Starlette",
    "version": "0.1.6",
    "split_keywords": [
        "sqlalchemy",
        "python3",
        "starlette",
        "gino"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fdaf5af7ab27d110950f1eeaafeed429db177c303074bf9f15af82c6ed2e828e",
                "md5": "d5bc731a3c53e0c8ec49dd54dc7372d1",
                "sha256": "6b2042c710bb65b5e4bc505d4b5c678ba41a5ba8a9e91136c03c7332cd638570"
            },
            "downloads": -1,
            "filename": "gino_starlette-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d5bc731a3c53e0c8ec49dd54dc7372d1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6.2,<4.0",
            "size": 6049,
            "upload_time": "2023-01-15T02:58:45",
            "upload_time_iso_8601": "2023-01-15T02:58:45.271795Z",
            "url": "https://files.pythonhosted.org/packages/fd/af/5af7ab27d110950f1eeaafeed429db177c303074bf9f15af82c6ed2e828e/gino_starlette-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8efbe60d828ec11c1ccd859708d1a32f1cfc1deef0f1a169a3ad3eb9c53b4937",
                "md5": "9f32a4e1d4f5d729b68fd942d132fcf7",
                "sha256": "16321616e17c0c8f6f8092630938e90479aed9ae63cff4311ded9fbd17b4e454"
            },
            "downloads": -1,
            "filename": "gino_starlette-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "9f32a4e1d4f5d729b68fd942d132fcf7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.2,<4.0",
            "size": 5713,
            "upload_time": "2023-01-15T02:58:47",
            "upload_time_iso_8601": "2023-01-15T02:58:47.078719Z",
            "url": "https://files.pythonhosted.org/packages/8e/fb/e60d828ec11c1ccd859708d1a32f1cfc1deef0f1a169a3ad3eb9c53b4937/gino_starlette-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-15 02:58:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "python-gino",
    "github_project": "gino-starlette",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "gino-starlette"
}
        
Elapsed time: 0.04529s