Giter Club home page Giter Club logo

gino-quart's Introduction

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.

gino-quart's People

Contributors

dependabot-preview[bot] avatar fantix avatar hummer12007 avatar spapadim avatar wwwjfy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.