Saravanan666/pypi-org huggingface dataset:
Package: django-database-files-3000
Django Database Files 3000This is a storage system for Django that stores uploaded
files in the database. Files can be served from the database
(usually a bad idea), the file system, or a CDN.InstallationSimply install via pip with:pip install django-database-files-3000UsageInsettings.py, adddatabase_filesto yourINSTALLED_APPSand add
this line:DEFAULT_FILE_STORAGE = 'database_files.storage.DatabaseStorage'Note, theupload_toparameter is still used to synchronize the files stored
in the database with those on the file system, so new and existing fields
should still have a value that makes sense from your base media directory.If you're using South, the initial model migrations will scan through all
existing models forFileFieldsorImageFieldsand will automatically
load them into the database.If for any reason you want to re-run this bulk import task, run:python manage.py database_files_loadAdditionally, if you want to export all files in the database back to the file
system, run:python manage.py database_files_dumpNote, that when a field referencing a file is cleared, the corresponding file
in the database and on the file system will not be automatically deleted.
To delete all files in the database and file system not referenced by any model
fields, run:python manage.py database_files_cleanupSettingsDB_FILES_AUTO_EXPORT_DB_TO_FS=True|False(defaultTrue)If true, when a file is uploaded or read from the database, a copy will be
exported to your media directory corresponding to the FileField's upload_to
path, just as it would with the default Django file storage.If false, the file will only exist in the database.DATABASE_FILES_URL_METHOD=URL_METHOD_1|URL_METHOD_2(defaultURL_METHOD_1)Defines the method to use when rendering the web-accessible URL for a file.IfURL_METHOD_1, assumes all files have been exported to the filesystem and
uses the path corresponding to yoursettings.MEDIA_URL.IfURL_METHOD_2, uses the URL bound to thedatabase_fileview
to dynamically lookup and serve files from the filesystem or database.In this case, you will also need to updates yoururls.pyto include the view
that serves the files:urlpatterns = patterns('',
      # ... the rest of your URLconf goes here ...

      # Serve Database Files directly
      url(r'', include('database_files.urls')),
  )DevelopmentTests require the Python development headers to be installed, which you can install on Ubuntu with:sudo apt-get install python-dev python3-dev python3.4-devTo run unittests across multiple Python versions, install:sudo apt-get install python3.4-minimal python3.4-dev python3.5-minimal python3.5-devNote, you may need to enable anadditional repositoryto provide these packages.To run alltests:export TESTNAME=; toxTo run tests for a specific environment (e.g. Python 2.7 with Django 1.4):export TESTNAME=; tox -e py27-django15To run a specific test:export TESTNAME=.test_adding_file; tox -e py27-django15To build and deploy a versioned package to PyPI, verifyall unittests are passing, and then run:python setup.py sdist
python setup.py sdist upload
Package: django-database-for-apps
django-database-for-appsdjango-database-for-appsis a package that provides a router which chooses
a database based on app name.InstallationInstall withpiporpipenv:pipinstalldjango-database-for-appsAdddjango_database_for_appsto your installed apps in your
settings.py file:INSTALLED_APPS=['django_database_for_apps',...]Configure DB routers:DATABASE_ROUTERS=['django_database_for_apps.Router']Configuration# list of apps and theirs databaseDATABASE_FOR_APPS={'test_project':'default','*':'django',}*matches all applications so the default database might be redefined from'default'to something else.Optional# allows relations between databases (default: None)DATABASE_FOR_APPS_RELATIONS=TrueDocumentationSeehttp://django-database-for-apps.readthedocs.org/LicenseCopyright © 2019, Piotr RoszatyckiThis software is distributed under the GNU Lesser General Public License (LGPL
3 or greater).
Package: django-database-locks
Distributed locks for Django using DB (MySQL/Postgres)Given the limitation that Percona Cluster does not support MySQL locks, this app implements locks usingselect_for_update()(row locks).Installationpip install django-database-locksUsagedjango-database-locksexposes one single thelockcontextmanager and thelockeddecorator.Thelockeddecorator will wrap a django management command (subclasses ofdjango.core.management.base.BaseCommand) or any function with thelockcontextmanager:fromdjango.core.management.baseimportBaseCommandfromdatabase_locksimportlocked@lockedclassCommand(BaseCommand):...defhandle(self,*args,**options):self.stdout.write('Got the lock')fromdatabase_locksimportlockedclassSomeClass:defnon_locked(self):pass@lockeddeflocked(self):print('got lock')fromdatabase_locksimportlockclassSomeClass:defnon_locked(self):passdeflocked(self):withlock():print('got lock')DocsBothlockandlockedhave the same optional args::paramlock_name:uniquenameinDBforthisfunction:paramtimeout:numbersofsecondstowaittoacquirelock:paramlock_ttl:expirationtimerofthelock,inseconds(settoNonetoinfinite):paramlocked_by:owneridforthelock(iflockisactivebutowneristhesame,returnsacquired):paramauto_renew:ifsettoTruewillre-acquirelock(for`lock_ttl`seconds)before`lock_ttl`isover.auto_renewthreadwillraiseKeyboardInterruptonthemainthreadincasere-acquiringfails:paramretry:retryevery`retry`secondsacquiringuntilsuccessful.settoNoneor0todisable.:paramlost_lock_cb:callbackfunctionwhenlockislost(whenre-acquiring).defaultstoraisingLockExceptionThere are also the following options you can specify in the projectsettings.pyDATABASE_LOCKS_STATUS_FILE: file that will be updated with the lock status (defaultNone). Useful when you have multiple shared-lock processes, to quickly inspect which one has the lock.DATABASE_LOCKS_ENABLED: set toFalseto globally disable locks (defaultTrue)DATABASE_LOCKS_DEFAULT_TTL: global lock TTL value (default10) which is ignored whenlock_ttlis specifiedDATABASE_LOCKS_DEFAULT_TTL_RENEW: number of seconds to renew lock before TTL expires (default2)TestingTox is used by the Github Action to test several python and django versions, with both MySQL and Postgres.To quickly test locally, kick off a MySQL and/or Postgres docker container:docker run -d –name locks-test-p 8877:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7docker run -d –name locks-test-psql-p 8878:5432 -e POSTGRES_PASSWORD=postgres postgres:10List available environments withtox -land then run the one you want/have:tox -e py39-dj32-mysql
# or
tox -e py39-dj32-postgresql -e py39-dj32-mysql
Package: django-database-logger
Alpha: DO NOT USE IN PRODUCTION
Database logger is a Django app that allows you to log on a database
table using standard logging commands. It can hook on existing logging
handlers and start storing them in the databaseQuick startAdd “database_logger” to your INSTALLED_APPS setting like this:INSTALLED_APPS = [
    ...
    'database_logger',
]Runpython manage.py migrateto create the models.Configure ….
Package: django-database-pool
通过DBUtils库实现Django数据库连接池，目前支持mysql、postgresql 数据库.下面的配置参考：DATABASES={'default':{'ENGINE':'djdbpool.db.backends.mysql',"HOST":"127.0.0.1","NAME":"test_db","PASSWORD":"","USER":"django","PORT":3306,'OPTIONS':{'charset':'utf8mb4'},'POOL':{# 更多的配置请参考DBUtils的配置'minsize':5,# 初始化时，连接池中至少创建的空闲的链接，0表示不创建，不填默认为5'maxsize':10,# 连接池中最多闲置的链接，0不限制，不填默认为0'maxconnections':60,# 连接池允许的最大连接数，0表示不限制连接数, 默认为0'blocking':True,# 连接池中如果没有可用连接后，是否阻塞等待。True:等待；False:不等待然后报错, 默认False'ping':0# 检查服务是否可用 1检查0不检查}}}
Package: django-database-postgresql-aad-backend
django_database_postgresql_aad_backenddjango-database-postgresql-aad-backend is a django database backend that adds Azure active directory authentication for
your Azure postgresql server. It uses the authentication as described in Azure documentation :https://docs.microsoft.com/en-us/azure/postgresql/howto-configure-sign-in-aad-authentication.This backend is based on Django postgresql backend (which it inherits from all its features) and adds AAD options in
database settings as described bellow :DATABASES = {
    "default": {
        "ENGINE": "django_database_postgresql_aad_backend",
        "NAME": os.getenv("DB_NAME"),
        "HOST": os.getenv("DB_HOST"),
        "PORT": os.getenv("DB_PORT"),
        "USER": os.getenv("DB_USERNAME"),
        "PASSWORD": "",
        "OPTIONS": {
            "sslmode": "require"
        },
        "AAD_OPTIONS": {
            "SP_CLIENT_ID": os.getenv("DB_SP_CLIENT_ID"),
            "`SP_CLIENT_SECRET`": os.getenv("DB_SP_CLIENT_SECRET"),
            "`SP_TENANT_ID`": os.getenv("DB_SP_TENANT_ID"),
        }
    }
}To enable Azure Active directory authentication you need to :Installdjango_database_postgresql_aad_backendusing pip :pip install django_database_postgresql_aad_backendAdd the backend to installed apps insetting.pyINSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'django_database_postgresql_aad_backend',
]ProvideAAD_OPTIONSdictionary inside database settings with the following keys :SP_CLIENT_ID(Required) The client ID of the service principal used to authenticate to Azure Active directory.SP_CLIENT_SECRET: (Required) The client secret of the service principal used to authenticate to Azure active directory.SP_TENANT_ID: (Required) The tenant ID of the service principal.REFRESH_BEFORE_MINUTES: (Optional) This is used to specify how much time (in minutes) the token should be valid.
Default value is 5.If you don't provideAAD_OPTIONSdictionary, Azure active directory authentication will be disabled and the backend
will use the default user/password authentication method.TestsTo run tests :python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
coverage run --source django_database_postgresql_aad_backend -m unittest discover 
coverage reportBuilding packageTo build package :python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
python3 setup.py sdist bdist_wheelPublish packagetwine upload --repository-url https://test.pypi.org/legacy/ dist/*ImprovementsThe token is fetched and stored in memory. An improvement would be to support a caching system to store token
and share it between multiple instances of the backend.Add more test cases !
Package: django-database-prefix
django-database-prefixAbles you to set Django's database tables prefix, as a result you can run multiple Django projects using single database, without any actions on the unmanaged tables.InstallationInstall using pippip install django-database-prefixAdddjango-database-prefixat the top of theINSTALLED_APPSto make it initialized first.'django_database_prefix',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',ConfigurationSet string value forDB_PREFIXin the settings.pyDB_PREFIX = 'app1_'In result you'll haveapp1_django_sessiontalbe names pattern.
Package: django-database-routing
django-database-routingProvides Primary/Replica database router for Django.
Seehttps://docs.djangoproject.com/en/dev/topics/db/multi-db/#an-examplefor example implementation.ConfigurationAdd router to settings.pyDATABASE_ROUTERS=['database_routing.PrimaryReplicaRouter']Configure 'default' and 'replica' connections insettings.DATABASESIf needed you can force specific connections for some apps or models:PRIMARY_REPLICA_ROUTING={'my_app.MyModel':{'read':'custom_connection','write':'custom_connection}}Forcing reading from primaryWhen transaction isolation level or replication lag causing bugs in your project, you can force your code
to read all the data fromdefault(or primary) database.fromdatabase_routingimportforce_primary_read@force_primary_readdefdo_some_reads_and_updates():# All Django ORM queries are going to 'default' database here.# ...
Package: django-database-size
django-database-sizeAdds a page to Django admin that lists the size of all tables in the database.Installationpython setup.py installOr via pip with:pip install django-database-sizeInstall the appropriate view in /sql (currently only PostgreSQL and MySQL supported).Add to your INSTALLED_APPS.UsageBrowse to /admin/database_size/.DevelopmentTo run unittests across multiple Python versions, install:sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python-dev python3-dev python3.3-minimal python3.3-dev python3.4-minimal python3.4-dev python3.5-minimal python3.5-dev python3.6 python3.6-devTo run alltests:export TESTNAME=; toxTo run tests for a specific environment (e.g. Python 2.7 with Django 1.4):export TESTNAME=; tox -e py39-django2To run a specific test:export TESTNAME=.test_example; tox -e py27-django15To run thedocumentation serverlocally:mkdocs serve -a :9999Todeploy documentation, run:mkdocs gh-deploy --cleanTo build and deploy a versioned package to PyPI, verifyall unittests are passing, and then run:python setup.py sdist
python setup.py sdist upload
Package: django-database-storage
This is a utility for Django that implements the Django Storage API (for
storing FileFields, ImageFields, etc.) and stores the contents of the files in
your Django database instead of on the filesystem.This is mainly intended to be an easy-to-use way to store file attachments and
get rid of the pain of managing filesystem access at run time, and the
deployment issues that come with it.  If your file attachment needs are
simple, this will generally be a quick way to get your app working.Features:Store any file in any database supported by Django.Simplify deployment and data management: No need to keep track of file
attachments when migrating data from one server to another, since files live
in the database.Limitations:Django does not support binary fields (issue #2417) and as of this writing,
expects queries to always return unicode data (issue #5135).  As a result,
this library uses base64 encoding to make binary data safe for the database,
which inflates data size by about 33%.Databases are not always built with large file storage in mind (unlike
filesystems).  As such, this is based on the assumption that files are
“reasonably” sized, meaning well under 1MB.  Files are entirely loaded into
RAM during requests. Your mileage may vary.No performance guarantees whatsoever.  The idea is that these are small
image attachments for a blog or similar, not that you are hosting a Youtube
clone in your Django database.Getting StartedInstall (pip install django-database-storage)Read the help:$ ./manage.py shell
…
>>> from database_storage import DatabaseStorage
>>> help(DatabaseStorage)License and CopyrightLicense: BSDOriginally derived from this snippet, although almost entirely rewritten for
better robustness and clarity:http://djangosnippets.org/snippets/1305/Copyright 2011 Mike Mueller,mike@subfocal.net.
Original copyright 2009 (c) GameKeeper Gambling Ltd, Ivanov E
Package: django-database-storage-backend
django-database-storage-backendA Django 1.10+/2.x storages backend backed by your existing database.This module provides an app nameddbstorage. The app contains a single modelStoredFilewhich is where files stored with the storage backend are put. The app also providesDatabaseStoragewhich you can set on your file fields.UsageInstall libmagic, e.g.:brew install libmagicInstall this package:pip django-database-storage-backendPut'dbstorage'in yourINSTALLED_APPSin yoursettings.py.Add to yoursettings.py:DEFAULT_FILE_STORAGE = 'dbstorage.storage.DatabaseStorage'Add to yoururls.pyURLconf:url(r'^user-media/', include('dbstorage.urls')),user-media/determines the URL path where media files are accessed from. You can set this to anything.Add a File or ImageFile field to your model:image = models.ImageField(upload_to='some-root')Files saved into this field will be stored in the database and available at the URL path/user-media/some-root/{HASH}.{EXT}.HASHis the SHA-1 hash of the file content. The file extension is replaced with a normalized file extension by auto-detecting the file type so that no file name information besides the file's type is leaked. This also prevents unauthorized users from randomly guessing the URLs to uploaded files (although SHA-1 is generally deprecated for security purposes in favor of SHA-256 --- so don't use this as your only form of authorization logic if it matters).Theupload_tovalue cannot be more than 200 characters as the maximum full path length is 255 characters.FeaturesEasily configure a media storage backend that just uses your existing database for storing and serving your media files.Filenames don't leak the name of the file that it was uploaded from and are based on a hash of the file's content to prevent unauthorized users from guessing file URLs.Secure headers are set to prevent untrusted content from being a cross-site scripting vulnerability.The backend supports thedelete,exists,listdir,size,url,created_time, andmodified_timefunctions.Stored files appear in the Django admin.Dynamic image resizingWhen storing images, the view method can automatically resize an image to one of a few pre-defined sizes. To use this feature, you must installpillow. Then add?width=plusxs(768px),sm(1024 px),md(1100px), orlg(1400px) to the URL when accessing the image. The image returned in the response will have this size as a maximum dimension.For Project MaintainersTo publish a universal wheel to pypi::pip3 install twine
    rm -rf dist
    python3 setup.py bdist_wheel --universal
    twine upload dist/*
    git tag v1.0.XXX
    git push --tags
Package: django-database-url
This simple Django utility allows you to utilize the12factorinspiredDATABASE_URLenvironment variable to configure your Django application.Thedj_database_url.configmethod returns a Django database connection
dictionary, populated with all the data specified in your URL. There is
also aconn_max_ageargument to easily enable Django’s connection pool.If you’d rather not use an environment variable, you can pass a URL in directly
instead todj_database_url.parse.Supported DatabasesSupport currently exists for PostgreSQL, PostGIS, MySQL, MySQL (GIS),
Oracle, Oracle (GIS), Redshift, and SQLite.InstallationInstallation is simple:$ pip install dj-database-urlUsageConfigure your database insettings.pyfromDATABASE_URL:import dj_database_url

DATABASES['default'] = dj_database_url.config(conn_max_age=600)Provide a default:DATABASES['default'] = dj_database_url.config(default='postgres://...')Parse an arbitrary Database URL:DATABASES['default'] = dj_database_url.parse('postgres://...', conn_max_age=600)Theconn_max_ageattribute is the lifetime of a database connection in seconds
and is available in Django 1.6+. If you do not set a value, it will default to0which is Django’s historical behavior of using a new database connection on each
request. UseNonefor unlimited persistent connections.URL schemaEngineDjango BackendURLPostgreSQLdjango.db.backends.postgresql[1]postgres://USER:PASSWORD@HOST:PORT/NAME[2]PostGISdjango.contrib.gis.db.backends.postgispostgis://USER:PASSWORD@HOST:PORT/NAMEMSSQLsql_server.pyodbcmssql://USER:PASSWORD@HOST:PORT/NAMEMySQLdjango.db.backends.mysqlmysql://USER:PASSWORD@HOST:PORT/NAMEMySQL (GIS)django.contrib.gis.db.backends.mysqlmysqlgis://USER:PASSWORD@HOST:PORT/NAMESQLitedjango.db.backends.sqlite3sqlite:///PATH[3]SpatiaLitedjango.contrib.gis.db.backends.spatialitespatialite:///PATH[3]Oracledjango.db.backends.oracleoracle://USER:PASSWORD@HOST:PORT/NAME[4]Oracle (GIS)django.contrib.gis.db.backends.oracleoraclegis://USER:PASSWORD@HOST:PORT/NAMERedshiftdjango_redshift_backendredshift://USER:PASSWORD@HOST:PORT/NAME[1]The django.db.backends.postgresql backend is named django.db.backends.postgresql_psycopg2 in older releases. For
backwards compatibility, the old name still works in newer versions. (The new name does not work in older versions).[2]With PostgreSQL, you can also use unix domain socket paths withpercent encoding:postgres://%2Fvar%2Flib%2Fpostgresql/dbname.[3](1,2)SQLite connects to file based databases. The same URL format is used, omitting
the hostname, and using the “file” portion as the filename of the database.
This has the effect of four slashes being present for an absolute file path:sqlite:////full/path/to/your/database/file.sqlite.[4]Note that when connecting to Oracle the URL isn’t in the form you may know
from using other Oracle tools (like SQLPlus) i.e. user and password are separated
by:not by/. Also you can omitHOSTandPORTand provide a full DSN string or TNS name inNAMEpart.
Package: django-database-view
A simple pluggable application that allows to work with database views.Quick startInstall the package:pip install django-database-viewIn yourmodels.pycreate classes which extenddbview.models.DbViewlike this:fromdjango.dbimportmodelsfromdbview.modelsimportDbViewclassModelA(models.Model):fielda=models.CharField()fieldc=models.IntegerField()classMyView(DbView):fieldA=models.OneToOneField(ModelA,primary_key=True,db_column='fielda__id')fieldB=models.IntegerField(blank=True,null=True,db_column='fieldb')@classmethoddefview(cls):"""
        This method returns the SQL string that creates the view,
        in this example fieldB is the result of annotating another column
        """qs=modelA.objects.all().annotate(fieldb=models.Sum('fieldc'),).annotate(fielda__id=models.F('pk'),).order_by('fielda__id',).values('fielda__id','fieldb',)returnstr(qs.query)Alternativelyget_view_strmethod could be used to write a custom SQL:classMyView(DbView):# ...@classmethoddefget_view_str(cls):return"""
            CREATE VIEW my_view AS (
            SELECT ...
        )"""Then create a migration point for your view generation, edit that
migration and modify it, add:from dbview.helpers import CreateViewand replace the line the
call tomigrations.CreateModelwithCreateView.Migrate your database and start using your database views.
Package: django-database-views
Serve your single page Javascript applications from Django.DocumentationThe full documentation is athttps://django-database-views.readthedocs.io.RequirementsDjango > 1.8A database engine such as MySQLQuickstartInstall django-database-views using pip:pip install django-database-viewsAdd it to your installed apps:INSTALLED_APPS = (
    ...
    'database_views.apps.DatabaseViewsConfig',
    ...
)Create a model to store versions for your index template in your app’s models.py:from database_views.models import AbstractTemplate


class IndexTemplate(AbstractTemplate):

    class Meta:
        db_table = 'your_table_name' # For example 'index_template'.Create a class-based view for your single page app in your app’s views.py and assign your model
to itsmodelproperty:from database_views.views import DatabaseTemplateView
from database_views.views import CachedTemplateResponse
from myapp.models import IndexTemplate


class IndexView(DatabaseTemplateView):
    app_name = 'main'
    model = IndexTemplate
    response_class = CachedTemplateResponseAdd a route for your index page view in your project’s urls.py file:from myapp.views import IndexView

urlpatterns = [
    ...
    url(r'^$', IndexView.as_view())
    ...
]That’s it!! Go to your new route and you should see your single page app’s index template served.
Please ensure that you configure the serving of your app’s static assets properly.FeaturesEasily serve your single page javascript applications from Django.Optionally cache your templates for a configurable amount of time.Works with ember-cli-deploy and more specifically withember-cli-deploy-mysql.Running TestsTo run tests use the following commands from the root of this project:source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ py.testCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.1.0 (2017-03-10)First release on PyPI.