Saravanan666/pypi-org huggingface dataset:
Package: django-db-introspection
# django-db-introspection```pip3 install django-db-introspection```Django 数据库内省工具, 通过数据表名就可以动态创建一个即时可用的Django models对象。仅仅需要一个表名，你就可以立即得到一个可用的Django 模型，并立即进行查询，更新等操作，开箱即用。目前版本暂时不支持外键关联关系。# -------------------------------Django database introspection tool, through the data table name can dynamically create a Django models ready-to-use objects.Just need a table name, you can immediately get a usable Django model, and immediately query, update and other operations, out of the box.The current version does not support foreign key relationships.# -------------------------------```In [4]: from django-db-introspection.introspection import get_my_modelsIn [5]: client_device_user = ModelFactory('monkey_king', 'client_device_user').modelsclass ClientDeviceUser(models.Model):box_id = models.CharField(max_length=20)device_id = models.CharField(max_length=50, blank=True, null=True)user_id = models.CharField(max_length=37)name4user = models.CharField(max_length=50, blank=True, null=True)email = models.IntegerField(blank=True, null=True)sms = models.IntegerField(blank=True, null=True)voice = models.IntegerField(blank=True, null=True)push = models.IntegerField(blank=True, null=True)master = models.IntegerField(blank=True, null=True)agent = models.IntegerField(blank=True, null=True)class Meta:db_table='client_device_user'/usr/local/lib/python3.5/dist-packages/django/db/models/base.py:325: RuntimeWarning: Model 'monkey_king.clientdeviceuser' wasalready registered. Reloading models is not advised as it can lead to inconsistencies, most notably with related models.new_class._meta.apps.register_model(new_class._meta.app_label, new_class)0.019804232000751654In [6]: client_device_user.objects.first().box_idOut[6]: '01J01ELQ15'In [7]:```
Package: django-db-locking
UsageThe simplest use is by using it as a context manager:with NonBlockingLock.objects.acquire_lock(obj=model_obj):
    model_obj.do_something()Or you can keep track of the lock yourself:try:
    lock = NonBlockingLock.objects.acquire_lock(obj=model_obj)
except AlreadyLocked:
    return False

model_obj.do_something()
lock.release()If you have no Django model, or you want to be able to specify the lock name
yourself, you can do that too:# this will raise AlreadyLocked, if it's locked
lock = NonBlockingLock.objects.acquire_lock(lock_name='my_lock')
do_something()
lock.release()Note that locks can expire automatically. There is aLOCK_MAX_AGEsettings where you can specify a default lock release value for locks in your entire Django codebase. This value can be overridden per lock by setting themax_ageparameter.TestYou can run the tests withtoxReleasesv2.0.0:Merging of master and pre-django-1.8 branches
Removes management command in favor of a celery taskv1.2.1:Fix problem in migration to UUIDField for PostGresv1.2.0:Move id to UUIDField, add code quality checks and CIv1.1.0:Rename model to NonBlockingLock and add additional featuresv1.0.1:Corrected tests and code clean-upv1.0.0:Intial release.
Package: django-dblog
Django Database Logsis an
Apache2 licensed Django application that enables logging to the database.QuickstartInstalling Django Database Logs is simple withpip:$ pip install django-dblogChanges tosettings.pyexample:INSTALLED_APPS += ['dblog']

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'dblog': {
            'class': 'dblog.DBLogHandler',
        },
    },
    'loggers': {
        'dblog': {
            'handlers': ['dblog'],
            'level': 'DEBUG',
            'propagate': False,
        },
    },
}Using the logger, example:import logging

dblog = logging.getLogger('dblog.' + __name__)

dblog.info('This message will go in the dblog Record table.')Reference and IndicesDjango Database Logs DocumentationDjango Database Logs at PyPIDjango Database Logs at GitHubDjango Database Logs Issue TrackerDjango Database Logs LicenseCopyright 2018-2022 Grant JenksLicensed under the Apache License, Version 2.0 (the “License”); you may not use
this file except in compliance with the License. You may obtain a copy of the
License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
Package: django-db-logger
Django logging in database.
For large projects please useSentryScreenshotDependencyDjango>=1.9Python 2.7+/3.6+LicenseWTFPLQuick startInstallpipinstalldjango-db-loggerAdd “django_db_logger” to yourINSTALLED_APPSsetting like thisINSTALLED_APPS=(...'django_db_logger',)Add handler and logger toLOGGINGsetting like thisLOGGING={'version':1,'disable_existing_loggers':False,'formatters':{'verbose':{'format':'%(levelname)s%(asctime)s%(module)s%(process)d%(thread)d%(message)s'},'simple':{'format':'%(levelname)s%(asctime)s%(message)s'},},'handlers':{'db_log':{'level':'DEBUG','class':'django_db_logger.db_log_handler.DatabaseLogHandler'},},'loggers':{'db':{'handlers':['db_log'],'level':'DEBUG'},'django.request':{# logging 500 errors to database'handlers':['db_log'],'level':'ERROR','propagate':False,}}}Runpython manage.py migrateto create django-db-logger models.Usedjango-db-loggerlike thisimportloggingdb_logger=logging.getLogger('db')db_logger.info('info message')db_logger.warning('warning message')try:1/0exceptExceptionase:db_logger.exception(e)OptionsDJANGO_DB_LOGGER_ADMIN_LIST_PER_PAGE: integer. list per page in admin view. default10DJANGO_DB_LOGGER_ENABLE_FORMATTER: boolean. Usingformatteroptions to format message.TrueorFalse, defaultFalseBuild your own database logger :hammer:Create a new app and add it toINSTALLED_APPSCopy filesdjango-db-logger/models.py,django-db-logger/admin.py,django-db-logger/db_log_handler.pyto the app folderReplaceDJANGO_DB_LOGGER_ADMIN_LIST_PER_PAGEinadmin.pywith an integerReplaceDJANGO_DB_LOGGER_ENABLE_FORMATTERindb_log_handler.pywithTrueorFalse. RemoveMSG_STYLE_SIMPLE, it was not used.Replace logger classdjango_db_logger.db_log_handler.DatabaseLogHandlerin your Settings with the new logger classCustomize the looger to meet your needs. :beer:
Package: django-db-log-plugin
Custom DB Log Handler for Django Projects.DocumentationThe full documentation is athttps://django-db-log.readthedocs.io.FeaturesCapture logs and save them in database.Examine logs in the administration page of the website.Job scheduler to delete old logs from the database.QuickstartInstall Django DB Log:pip install django-db-log-pluginAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'django_apscheduler','django_db_log',...)Add Django DB Log’s URL patterns:fromdjango_db_logimporturlsasdjango_db_log_urlsurlpatterns=[...url(r'^',include(django_db_log_urls)),...]Add the LOGGING configuration in the settings.py file.LOGGING={'version':1,'disable_existing_loggers':False,'formatters':{'verbose':{'format':'[%(asctime)s]%(levelname)s%(module)s.%(funcName)s%(lineno)d:%(message)s'},'simple':{'format':'%(levelname)s%(message)s',},},'handlers':{'log_db':{'level':'ERROR','class':'django_db_log.handlers.DBHandler','model':'django_db_log.models.ErrorLog','expiry':86400,'formatter':'simple',},},'loggers':{'django':{'handlers':['log_db'],'level':'ERROR','propagate':False,},},}Add the following constants in your settings file. These will be used to determine the lookup days to delete old logs from db.INTERVAL_SCHEDULER_JOB_SECONDS=43200GENERAL_LOGS_DELETE_DAYS=2INFO_LOGS_DELETE_DAYS=2DEBUG_LOGS_DELETE_DAYS=2ERROR_LOGS_DELETE_DAYS=10Run migrationspythonmanage.pymigrateRunning TestsDoes the code actually work?source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ toxCreditsDjango_APSchedulerTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.1.0 (2018-08-29)First release on PyPI.
Package: django-dblogs
# dblogsa package to add logging handlers to write logs into database in django project# Quick start1. Add "dblogs" to your INSTALLED_APPS settings;2. Config loggings handlers to log stuff:'handlers':{'log_db':{'level': 'WARNING','class': 'dblogs.handlers.DBHandler',# model and expiry can be configured to your preference# the default is dblogs.GeneralLog model and expiry is in no effect'model': 'your.data.model','expiry': 10000, # unit is seconds'formatter': 'simple',},}3. Include the polls URLconf in your project urls.py;4. Run 'python manage.py migrate' to create models to store logs;
Package: django-db-logs
DisclaimerUpdate from django-db-logger, due to inactivity of the original package.Original readmeDjango logging in database.
For large projects please useSentryScreenshotDependencyDjango>=1.9Python 2.7+/3.6+LicenseMITQuick startInstallpipinstalldjango-db-logsAdd “django_db_logs” to yourINSTALLED_APPSsetting like thisINSTALLED_APPS=(...'django_db_logs',)Add handler and logger toLOGGINGsetting like thisLOGGING={'version':1,'disable_existing_loggers':False,'formatters':{'verbose':{'format':'%(levelname)s%(asctime)s%(module)s%(process)d%(thread)d%(message)s'},'simple':{'format':'%(levelname)s%(asctime)s%(message)s'},},'handlers':{'db_log':{'level':'DEBUG','class':'django_db_logs.db_log_handler.DatabaseLogHandler'},},'loggers':{'db':{'handlers':['db_log'],'level':'DEBUG'}}}Runpython manage.py migrateto create django-db-logs models.Usedjango-db-logslike thisimportloggingdb_logs=logging.getLogger('db')db_logs.info('info message')db_logs.warning('warning message')try:1/0exceptExceptionase:db_logs.exception(e)OptionsDJANGO_db_logs_ADMIN_LIST_PER_PAGE: integer. list per page in admin view. default10DJANGO_db_logs_ENABLE_FORMATTER: boolean. Usingformatteroptions to format message.``True`` orFalse, defaultFalse
Package: django-dbmanager
django-dbmanager is a Django app to use for stockanalyser. For each question,
visitors can choose between a fixed number of answers.Quick startAdd “dbmanager” to your INSTALLED_APPS setting like thisINSTALLED_APPS = [
    ...
    'dbmanager',
]Add the namespace in urlpattern like thisurlpatterns = [
...
  path('dbmanager/', include('dbamanger.urls', namespace='dbmanager')),
]Usage in the template{% load dbmanager_custom_tags %}
...
{% dbsetting %}If you want to see appropriate html render, please use bootstrap 5.
Package: django-dbmessages
Almost like django.contrib.messages,
but doesn’t need request to message a user.In fact, django-dbmessages is but a very thin and simple layer
on top of Django’scontrib.messages.To message a user, you simply create and save an instance
of providedMessagemodel via shell, Django admin, or some other means.Messagemodel has all the same attributes you’d normally pass
tocontrib.messages(level, message, extra_tags),
and in addition a ForeignKey link to User model.The next time given user appears on the site, middleware provided by dbmessages
checks if user has any messages for them, and adds them to request using regularcontrib.messagesAPI. Then it deletes those messages from the DB.
Simple as that.Quick startMake sure to enable Django’scontrib.messagesin your project
(check the docs).Installdjango-dbmessages(it’s on PyPI).Add'dbmessages'to your INSTALLED_APPS
and'dbmessages.middleware.DBMessageMiddleware'to MIDDLEWARE_CLASSES.Synchronize (or migrate) the DB.Now you can get into shell and address a message to yourself:>>> from dbmessages.models import Message
>>> from django.contrib import messages
>>> Message.objects.create(to_user=your_user, level=messages.INFO, message="Ahoy there")Provided your front-end is integrated with Django’scontrib.messages,
you should see the “Ahoy there” message the next time you log in
under your account.
Package: django-dbml
Django DBML generatorThis app can generate a DBML output for all installed models.How to install and use?1. Install the django-dbml packagepip install django-dbml2. Put django_dbml on your django settings'...','django_dbml','...',3. Run the command to generate a DBML schema based on your Django models$pythonmanage.pydbmlTo generate DBML for a subset of your models, specify one or more Django app
names or models by app_label or app_label.ModelName. Related tables will still
be included in the DBML.ThanksThe initial code was based onhttps://github.com/hamedsj/DbmlForDjangoproject
Package: django-db-mutex
django-db-mutexProvides the ability to acquire a mutex lock from the database in Django.InstallationTo install the latest release, type:pip install django-db-mutexTo install the latest code directly from source, type:pip install git+git://github.com/ambitioninc/django-db-mutex.gitDocumentationFull documentation is available athttp://django-db-mutex.readthedocs.orgLicenseMIT License (see LICENSE)
Package: django-db-obfuscator
Django app to obfuscate text data. Originally develop byDipcode Software.CompatibilityTested with python 3.6, 3.7, 3.8 and Django 1.11 & 2.2:Travis CIHow to installTo install the app run:$pipinstalldjango-db-obfuscateror add it to the list of requirements of your project.Then add ‘obfuscator’ to your INSTALLED_APPS.INSTALLED_APPS=[...'obfuscator',]Example usageOn you django project settings, configure the model names and field
names to be obfuscated:OBFUSCATOR={'FIELDS':{'app_label.ModelClass1':['field1','field2','field3'],'app_label.ModelClass2':['field1'],//...}}Run the management command to start obfuscation:$pythonmanage.pyobfuscateYou can run the management command passing as arguments: a model class
path and a list of fields to obfuscate (thus will ignoreFIELDSsetting):$pythonmanage.pyobfuscate--model=app_label.ModelClass1--fields=field1,field2,field3Settings referenceOBFUSCATOR_CLASSDefault:obfuscator.utils.ObfuscatorUtilsPath to class where obfuscator methods are defined. By default, the
class define tow obfuscator methods: *text- Obfuscate simple text
data, respectingmax-lengthfield parameter; *email-
Obfuscate email data. Only text before@is obfuscated, respectingmax-lengthfield parameter.This class also define anobfuscatemethod. This method use fields
mapping (seeFIELDS_MAPPINGsetting) to route the field type with
the obfuscate method.You can redefine this class by subclassing the default class and
changing this setting to point to your class.FIELDS_MAPPINGDefault:OBFUSCATOR={'FIELDS_MAPPING':{models.CharField:'text',models.TextField:'text',models.EmailField:'email',models.IntegerField:'number',models.URLField:'text',//...}}Map django model field types with obfuscator methods.FIELDSDefault:{}Fields to be obfuscated and respective model class path. Must be adictwith keys as python dot notation to path where the models are
declared and the values must be declared as lists of model fields.If no value defined, the management command will do nothing.Example:OBFUSCATOR={'FIELDS':{'contenttypes.ContentType':['model','label'],//...}}LicenseMIT license, see the LICENSE file. You can use obfuscator in open source
projects and commercial products.TODOadd logic to handle superusers, if needed
Package: django-db-only
# <p align=”center”>django-db-onlyThis is just wrapper package on top of django framework, which creates django project with only standalone modules included.You can check releases in [Releases](https://github.com/abrorbekuz/django-db-only/releases)<br>
Our community [Telegram Group](https://t.me/django_db_only)## Howto1.install django-db-only:python setup.py installor just typepip install django-db-only2.create standalone django models project:` django_db_only startproject myproject cd myproject `3.migrate` python manage.py makemigrations <app_name> python manage.py migrate <app_name> `4.run application with standalone django models:` python query_resolver.py `
Package: django-dbpool
This project was based ondjango-postgrespool+django-postgrespool2(forked)(both are not working in my production env) anddjango-db-pool(outdated as fck).Django-DBPoolThis is a simple Postgres Connection Pooling backed for Django 1.4+ (possibly, haven’t checked), powered by SQLAlchemy and psycopg2.UsageUsing Django-PostgresPool is simple, just setdjango_postgrespoolas your connection engine:DATABASES = {
    'default': {
        'ENGINE': 'django_postgrespool'If you’re using thedj-database-urlmodule:import dj_database_url

DATABASES = {'default': dj_database_url.config(engine='django_postgrespool')}If you’re usingsouth:SOUTH_DATABASE_ADAPTERS = {
    'default': 'south.db.postgresql_psycopg2'
}Everything should work as expected.InstallationInstalling Django-PostgresPool is simple, with pip:$ pip install django-dbpoolConfigurationOptionally, you can provide additional options to pass to SQLAlchemy’s pool creation:DATABASE_POOL_ARGS = {
    'max_overflow': 10,
    'pool_size': 5,
    'recycle': 300
}Here’s a basic explanation of two of these options:pool_size– Theminimumnumber of connections to maintain in the pool.max_overflow– The maximumoverflowsize of the pool. This is not the maximum size of the pool.The total number of “sleeping” connections the pool will allow ispool_size.
The total simultaneous connections the pool will allow ispool_size + max_overflow.As an example, databases in theHeroku Postgresstarter tier have a maximum connection limit of 20. In that case yourpool_sizeandmax_overflow, when combined, should not exceed 20.Check out the officialSQLAlchemy Connection Poolingdocs to learn more about the optoins that can be defined inDATABASE_POOL_ARGS.Django 1.3 Supportdjango-postgrespool currently supports Django 1.4 and greater. Seethis ticketfor 1.3 support.
Package: django-db-pooling
django_db_poolingA patch to enable Django database connection pooling with gevent Gunicorn
workers.Usage Guidepip install django_db_poolingin wsgi.py:import os
 import pymysql
 from django.core.wsgi import get_wsgi_application
 from django_db_pooling import pooling

 pymysql.install_as_MySQLdb()

 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xxxxx.settings")

 application = get_wsgi_application()

 pooling.set_pool_size(4)
 pooling.apply_patch()setconn_max_ageto a value larger than 0 and less than MySQL'swait_timeout, e.g 60 seconds is usually
a good enough value.How it worksThe connection pool patches the__getitem__method ofdjango.db.utils.ConnectionHandlerin such a way so that the db connection
can be reused across multiple requests/green-lets untilconn_max_ageis
reached.By default, Django manage the database connection object in a thread local
attributed_connectionsindjango.db.utils.ConnectionHandlerso that
each thread has its own database connection object to avoid race condition.
It also allows reuse of database connection by specifying a positive value or
None onconn_max_agesetting to avoid initiating and releasing connection
for each request. However, it leads to problem when used with the gevent worker
in Gunicorn where the thread local attribute is patched by a green-let local
attribute: if a green-let is not reused, the database connection object
associated with green-let will not be released or recycled until it is garbage
collected or closed by MySQL. Under a medium or heavy load, those idle
connections may accumulate and the connection limit of MySQL is finally reached
so that no more new connection can be established.To solve the above issue, this patch adds a non-local attributeconnection_pool. It is a dictionary with keys being the connection alias name
and values being a list of pooled connection objects. Whenever a new request
starts, connection object in the pool will be reused if there is any or else new
connection object is created. The connection object will be bound to the_connectionsattribute to associate with the current request. Underlying
connection is closed and reopened if theconn_max_ageis reached. When current
request finishes, the connection object will be recycled to the pool if pool still
has capacity, which is set by the methodset_pool_size()(default to 1 if not
specified). Otherwise the connection object will be freed and the underlying
connection is closed immediately.Under extrem heavy load , it might be a good idea to restrict the concurrency per
worker in Gunicorn
(--worker_connections)
to ensure the overall concurrent database connections are less than the maximum
permitted simultaneous connections in MySQL
(--max_connections).
Alternatively, theset_pool_size()method accepts an additional argumentmax_outstanding(default toNonewhich means unlimited) to limit the maximum concurrent connections per worker basis.
Package: django-db-prefix
django_db_prefix================Project goal------------Allow specification of a global database table name prefix.Reason for the project----------------------1. Some (external) projects automatically use a database prefix forinteraction with a database. This is particularly common in implementationsof the Active Record pattern.2. It is possible to define an explicit database table name in the Metaclass on a model; however, this is not as easily accomplished when dealingwith a third-party application. By providing a high-level interface foradding prefixes there is a simple, consistent way to achieve this goal otherthan forking the code or ad-hoc monkey patching.Installation------------1. Install using pip:pip install django-db-prefix2. Add django_db_prefix at the top of your INSTALLED_APPS list. It isrecommended that django_db_prefix is the first listed application, but itis essential that it be loaded before the initialization of any model youexpect to be modified.INSTALLED_APPS = ['django_db_prefix',] + INSTALLED_APPSConfiguration-------------Global Prefix=============To add a common prefix to all models simply set `DB_PREFIX` to the string thatyou want to be prepended.DB_PREFIX = "foo_"For example, for the model bar_app.models.Baz the default table would be:`bar_app_baz`By setting `DB_PREFIX` to `foo_`, the table would be `foo_bar_app_baz`.
Package: django-db-quick-setup
Create and start MySQL/PostgreSQL containers with a single management command.If an image isn’t available, it will be pulled.If a container with the specified configuration doesn’t exist, it will be
created.If a container is not running, it will be started.Necessary settings are taken from settings.py.SQLite databases are ignored.For MySQL and PostgreSQL, one container is created per database.Also, Docker settings are picked up from standardDOCKER_*environment
variables.Usage./manage.pydb_quick_setup'db_quick_setup'should be added toINSTALLED_APPS:INSTALLED_APPS=('django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.sites','django.contrib.messages','django.contrib.staticfiles','django.contrib.admin','db_quick_setup')'HOST'in database settings should point to Docker hostname/IP. You can
usefind_docker_host()to auto-detect it.fromdb_quick_setupimportfind_docker_hostDATABASES={'default':{'ENGINE':'django.db.backends.mysql','NAME':'mysql_db','USER':'mysql_db','PASSWORD':'mysql_db_pass','HOST':find_docker_host(),'PORT':53308}}'NAME','USER','PASSWORD'and'PORT'can have arbitrary values,
the container will be configured accordingly.For MySQL'NAME'and'USER'should have the same value, it’s a
limitation of the official image.SettingsDOCKER_MYSQL_IMAGE: Docker image to use for MySQL databases. Default is the
official image -mysql:latest.DOCKER_POSTGRES_IMAGE: Docker image for PostgreSQL databases. Default is
the official image -postgresql:latest.DOCKER_ASSERT_HOSTNAME: enable SSL hostname validation (boolean).Trueby default.DOCKER_PRIVILEGED: create privileged containers. Currently used as a
workaround for permission problems on Travis CI. It is disabled by default,
and shouldn’t be enabled usually.