Skip to main content

Framework agnostic dependency injections

Project description

Knot Injector

Framework agnostic dependency injections

This library build as a wrapper for `Knot`_ Dependencies Container.


``pip install knot-injector``



.. code:: python

import sqlalchemy as db
from sqlalchemy.orm import sessionmaker

from knot_injector import Container

registry = Container()

settings = {
'db': {
'uri': 'sqlite://',
'echo': False,
'encoding': 'utf8',

registry.add_service(lambda _: settings, name='settings')

def dbengine(container, settings):
uri = settings['db']['uri']
return create_engine(uri, **settings['db'])

def database_session(container, dbengine):
session = sessionmaker()
return session()

class ItemResource(object):

def on_get(request, response, item_id, dbsession): = dbsession.query(Item).filter( == item_id).one()

.. _Knot:

Project details

Release history Release notifications

This version
History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
knot-injector-0.0.3.tar.gz (3.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page