Skip to main content

An extension for GINO to integrate with Quart

Project description

gino-quart

test

Introduction

An extension for GINO to support quart server.

Usage

The common usage looks like this:

from quart import Quart
from gino.ext.quart import Gino

app = Quart()
db = Gino(app, **kwargs)

Configuration

GINO adds a before_request, after_request and before_first_request hook to the Quart 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:

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

Contributing

You're welcome to contribute to this project. It's really appreciated. Please fork this project and create a pull request to the dev branch.

  • Dependency management is done via poetry
  • Pull request for new features must include the appropriate tests integrated in tests/test_gino_quart.py
  • You should format your code. Recommended is black

Attribution

The license holder of this extension is Tony Wang.

This project is an extension to GINO and part of the python-gino community.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gino-quart-0.1.1b2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gino_quart-0.1.1b2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file gino-quart-0.1.1b2.tar.gz.

File metadata

  • Download URL: gino-quart-0.1.1b2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1039-azure

File hashes

Hashes for gino-quart-0.1.1b2.tar.gz
Algorithm Hash digest
SHA256 7c78aab37b63d36784478aac9b6029d07f3f9690230429ce3bf4e965baa9b76c
MD5 584c8f24c6edcd3f2ceae3e26dc11d39
BLAKE2b-256 96b54591037fd76cdf6b1f15570a000f5d4877796478ca8fa17f51ae205af74e

See more details on using hashes here.

File details

Details for the file gino_quart-0.1.1b2-py3-none-any.whl.

File metadata

  • Download URL: gino_quart-0.1.1b2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1039-azure

File hashes

Hashes for gino_quart-0.1.1b2-py3-none-any.whl
Algorithm Hash digest
SHA256 ee07194240d2e32b04d3e0bfb20b799514920e2244338ef6da93d4a974bb852f
MD5 ca1dcfbcf32bf72a4820e5c014308cf0
BLAKE2b-256 31bac76f543f1e098843ee1f630baac2aafbfa9d7a8aef9aac5dd0b97ff7d95c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page