semvec/pypi-packages huggingface dataset:
RequestLogs 1.0dev
Request Log middleware
License: MIT

======================
Requset Log Middleware
======================

Request log middleware to capture meta data associated with each user request into mongo database. The write acknowledgement at time of save to mongo is disabled to ensure there is minimum performance lag due to this middleware.

Note: this is work in progress - expect bugs etc

Requirements
===========

* pymongo
* celery
* Mongo
* Elasti Search
* Tested on Django > 1.3

Setup / Installation
====================

* Install the package using pip
    pip install requestlogs

Update settings.py

* Add app 'requestlogs' to your INSTALLED_APPS

* Add 'requestlogs.middleware.RequestLogMiddleware' to MIDDLEWARE_CLASSES after auth

* Set the app name, this will be used in the collection / index etc
    RLOG_APP_NAME = 'app'  # used to uniquely identify the collection

* Set the engine / db where you want the logs to be captured
    RLOG_ENGINE = 'MONGO' or RLOG_ENGINE = 'ELASTICSEARCH'

* For MONGO: Customize the name and mongo connections
    RLOG_MONGODB_URI = 'mongodb://127.0.0.1:27017/requestlogs_db?w=0'  # mongodb to capture request logs
    # mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
    # refer: http://docs.mongodb.org/manual/reference/connection-string/

    - The collection name will be set to {RLOG_APP_NAME}_request_logs

* For ELASTICSEARCH: Customize the name and connections
    ELASTICSEARCH_CONN = [{'host': 'localhost', 'port': 9200}, ]
    RLOG_ELASTICSEARCH_TTL = "90d"  # set the TTL for auto expiry
    
    - The document type will be set to {RLOG_APP_NAME}-requestlogs
    - The index name will be set to idx-{RLOG_APP_NAME}-requestlogs
    - For Kibana - a customized dashboard has been created, change the type and index to use it

ToDos
=====
This package is still under development, following are the high level items to be implemented

* Capture custom session variable
* Add views to pull transactions by user
* Add views to search transactions by user and datetime
* Test cases
bottle-pgsql 0.2
PgSQL integration for Bottle
License: MIT

Bottle-PgSQL is based on Bottle-MySQL and Bottle-sqlite.
Bottle-PgSQL is a plugin that integrates PostgreSQL with your Bottle
application. It automatically connects to a database at the beginning of a
request, passes the database handle to the route callback and closes the
connection afterwards.

To automatically detect routes that need a database connection, the plugin
searches for route callbacks that require a `db` keyword argument
(configurable) and skips routes that do not. This removes any overhead for
routes that don't need a database connection.

Results are returned as dictionaries.

Usage Example::

    import bottle
    import bottle_pgsql

    app = bottle.Bottle()
    plugin = bottle_pgsql.Plugin('dbname=db user=user password=pass')
    app.install(plugin)

    @app.route('/show/:<item>')
    def show(item, db):
        db.execute('SELECT * from items where name="%s"', (item,))
        row = db.fetchone()
        if row:
            return template('showitem', page=row)
        return HTTPError(404, "Page not found")
bn 0.1.5
Lightweight profiling tool to detect performance BottleNecks in Python code.
License: MIT

Hence the name: bn - BottleNeck.  
And you know keys B and N are very comfortable to type quickly in a row.

Usage::

    bn('loop')
    for item in generator:

        bn('rabbit')
        # code of rabbit

        bn('turtle')
        # code of turtle

        bn('loop')

    if bn.total > 1.0:
        logging.info(bn)

Result::

    TOTAL=22.2632, turtle=20.6403, rabbit=1.6209, loop=0.0020
    #
    # This config is default in bn>=0.1.5:
    # Bn(total_key='TOTAL', format='{key}={seconds:.4f}', sep=', ')

    # OR:

    22.2632    TOTAL
    20.6403    turtle
     1.6209    rabbit
     0.0020    loop
    #
    # This config is default in bn<=0.1.4:
    # Bn(total_key='TOTAL', format='{seconds:>10.4f}    {key}', sep='\n')

Install::

    pip install bn

Scope::

    # Global "bn" is useful to profile cross-module without passing "bn" explicitly.
    from bn import bn
    bn.format = custom_format

    # Scoped "Bn" is useful to have multiple independent profilers.
    from bn import Bn
    def action():
        bn = Bn(format=custom_format)