{ "info": { "author": "R\u00e9gis Leroy", "author_email": "regis.leroy@makina-corpus.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Framework :: Django :: 1.10", "Framework :: Django :: 1.11", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Database", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=============================\nDjango PostgreSQL light Schemas support\n=============================\n\n.. image:: https://badge.fury.io/py/django_postgresql_light_schemas.svg\n :target: https://badge.fury.io/py/django_postgresql_light_schemas\n\n.. image:: https://travis-ci.org/regilero/django_postgresql_light_schemas.svg?branch=master\n :target: https://travis-ci.org/regilero/django_postgresql_light_schemas\n\n.. image:: https://codecov.io/gh/regilero/django_postgresql_light_schemas/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/regilero/django_postgresql_light_schemas\n\nSome PostgreSQl introspection fixs to support postgreSQL users binded to specific schemas,\nmultiple schemas on same database for various django installations.\nNo full schema support in models declarations(light).\nBased on model table name hack and PostgreSQl users using search_path variables.\n\nIf you need/want a deeper schema management search for other django PostgreSQL extensions, like:\n\n- https://github.com/ryannjohnson/django-schemas\n- https://github.com/bernardopires/django-tenant-schemas\n- https://github.com/damoti/django-postgres-schema\n\nSo, what is a light schema hack support, if you cannot declare the scema in the model?\n\nLet's say you use a postgres user binded to schema which is not `public`, **and/or**\nthat you use the *classical* trick of hacking the model table name to:\n\n.. code-block:: python\n\n (...)\n class Meta:\n managed = False\n db_table = 'my_schema\\\".\\\"foo'\n\nAnd you use a PostgreSQL user where the user's **`search_path` variable** is altered\nto at least includes `my_schema`. Note that by using a `search_path` variable which\ndoes not start by the public schema you will end up with Django tables set in the\nfirst schema in this list. **If you use only one schema you do not need to hack\nthe `db_table` reference as we made here**. `my_schema.` would be **implicit**\nfor PostgreSQL.\n\nBut if you use several schemas in the same django app you can use the trick for\nall tables which are not managed by django migrations.\n\n.. code-block:: sql\n\n -- Case1: you need to access tables in 3 schemas\n ALTER ROLE \"my_django-pg-user\" SET search_path='my_app,public,other';\n -- Or case 2 : tables are in your schema, priority, but you read things\n -- on the public schema also\n ALTER ROLE \"my_django-pg-user\" SET search_path='my_app,public';\n -- Or case 3 (we could continue on that): you access one schema only\n ALTER ROLE \"my_django-pg-user\" SET search_path='my_app';\n\nYou cannot use this hacked model to create migrations, unless you use only one\nschema and you do not hack the `db_table`. But in the two cases (one schema which\nis not public, or several schemas and db_table hacks on non default schemas) Django\nwould **mostly** work well.\n\nThis present module will help covering the small things which are not covered, i.e.:\n\n- you will be able to make migrations with foreign keys targeting theses hacked models,\n for other models which are not using the trick.\n- you will be able to install several Django applications on several schemas, all\n sharing the same database, if they all use this module.\n- in fact you will lock Django to the right schemas when doing introspection\n stuff, and avoid bad introspection locked in `public` or detecting stuff on\n other schemas.\n\nTested on Django **1.10** & **1.11**.\n\nDjango problems with schemas\n-----------------------------\n\nWhen using schemas and search_path, without this module, you would encounter\n2 problems:\n\n- all instrospections queries made by Django are performed on the catalog, and\n are not filtering schemas. All defeinitions, for all tables, all schemas, are\n visible on the PostgreSQL catalog (on Djangho 1.11 one the query is filtering on\n the public schema, the other are not filtered).\n So if you have several django applications installed on different schemas on the same database\n **you would see all tables from all installed Django applications** on most queries,\n same thing for indexes, and sometimes you would not detect existing tables or\n indexes (where the public schema filter is applied), big problems.\n Playing with the postgreSQl user **grants** cannot help you, even if the user has\n access to only one schema, all definitions would be visible in the catalog.\n This module will fix all the catalog queries to restrict visibility to a given\n list of schemas (like 'public' and 'my_app', or just 'my_app').\n- when building foreign keys reference from managed tables to unmanaged tables\n using the schema trick on `db_table` the `\".\"` injection would be reapplied on\n the constraint name, preventing the constraint creation.\n\nQuickstart\n----------\n\nInstall Django PostgreSQL light Schemas support (or use it in the requirements file)::\n\n pip install django_postgresql_light_schemas\n\nAdd it to your `INSTALLED_APPS`:\n\n.. code-block:: python\n\n INSTALLED_APPS = (\n ...\n 'django_postgresql_light_schemas',\n ...\n )\n\nFix your database connexion settings to use this module instead of the default\npostgresql connector (this module inherits most part of this connector).\n\n.. code-block:: python\n\n DATABASES = {\n 'default': {\n 'ENGINE': 'django_postgresql_light_schemas.engine',\n 'NAME': 'my_app',\n 'OPTIONS': {\n 'options': '-c search_path=foo,bar' # if search_path is not set\n },\n 'USER': 'my_app_user',\n (...)\n },\n }\n\n\nFinally, and this is **required** also, list the schema that your PostgreSQL user\nis able to access. As we will remove all informations from schemas which are not\nlisted there.\n\n.. code-block:: python\n\n # for django_postgresql_light_schemas, this is the list of schemas known to postgresql, for this application\n # if you do not work with schemas set:\n # SUPPORTED_SCHEMAS = ('public',)\n # if your application as one unique 'foo' schema, set:\n # SUPPORTED_SCHEMAS = ('foo',)\n # if you need several schemas 'public', 'foo', 'bar' and 'baz' set\n # SUPPORTED_SCHEMAS = ('public','foo','bar','baz',)\n # table and indexes set in other schemas WONT be detected by Django intropsection\n # tables and indexes MUST still be uniques in this list of schemas\n # i.e. do not try to have foo.table1 and bar.table1 if you both support foo and bar schemas\n # but that's bnot a problem if you only declare 'foo' in SUPPORTED_SCHEMAS.\n SUPPORTED_SCHEMAS = (\n 'public',\n 'foo',\n 'bar'\n )\n\nFeatures\n--------\n\n- Django 1.10 & 1.11\n- fix PostgreSQL introspection to limit visible schemas for Django\n- fix Foreign keys names referencing schema hacked db_table names\n- ... (if you find other issues, please report!)\n\nRunning Tests\n-------------\n\nDoes the code actually work?\n\n::\n\n source /bin/activate\n (myenv) $ pip install tox\n (myenv) $ tox\n\nCredits\n-------\n\nTools used in rendering this package:\n\n* Cookiecutter_\n* `cookiecutter-djangopackage`_\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage\n\n\n\n\nHistory\n-------\n\n0.1.0 (2018-01-30)\n++++++++++++++++++\n\n* First beta relase", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/regilero/django_postgresql_light_schemas", "keywords": "django,postgres,postgresql,schemas", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-postgresql-light-schemas", "package_url": "https://pypi.org/project/django-postgresql-light-schemas/", "platform": "", "project_url": "https://pypi.org/project/django-postgresql-light-schemas/", "project_urls": { "Homepage": "https://github.com/regilero/django_postgresql_light_schemas" }, "release_url": "https://pypi.org/project/django-postgresql-light-schemas/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Some PostgreSQl introspection fixs to support postgreSQL users binded to specific schemas, multiple schemas on same database for various django installations. No full schema support in models declarations(light).", "version": "0.2.1" }, "last_serial": 3540911, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d2694712a7ac17a768c8beb14e81e986", "sha256": "6581001a735f9947b5e80efce2e0cfb6fcd1ece0597d15d440965054b5e6d6ab" }, "downloads": -1, "filename": "django_postgresql_light_schemas-0.1.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "d2694712a7ac17a768c8beb14e81e986", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12905, "upload_time": "2018-01-31T08:22:56", "url": "https://files.pythonhosted.org/packages/99/b5/f968faf94d6cf393a7b3e2fc58acb76c40654ecba8b050b1949991cf718a/django_postgresql_light_schemas-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c93af11efcb6f5c7fef89eb724250b57", "sha256": "a66f31a1c5324bb38c92487421dacbfe74a979a88c0435c28813d4ab8993b337" }, "downloads": -1, "filename": "django_postgresql_light_schemas-0.1.0.tar.gz", "has_sig": true, "md5_digest": "c93af11efcb6f5c7fef89eb724250b57", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10884, "upload_time": "2018-01-31T08:22:43", "url": "https://files.pythonhosted.org/packages/b2/75/c2e6497d4015381f3745e14363ad0c71a278d3833259fe8de720f2f1461d/django_postgresql_light_schemas-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "7e8da403389cc92fe620cf8669a8a053", "sha256": "dc16c6b5268661a6640076e69e4f25c9c9722c8bf4402b22cf997a08a4963c2a" }, "downloads": -1, "filename": "django_postgresql_light_schemas-0.2.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "7e8da403389cc92fe620cf8669a8a053", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13102, "upload_time": "2018-01-31T08:49:26", "url": "https://files.pythonhosted.org/packages/77/53/a4deeaae69f44fce2887e5668cd1d7d890c63f4bcb30a9c00f9ea88cde58/django_postgresql_light_schemas-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e8b584ef1a3b632eb9cd2bfcdadae221", "sha256": "e8d4297e9ded5c33295b8a2b37d17a76a107d415c75083b06e3446f569147109" }, "downloads": -1, "filename": "django_postgresql_light_schemas-0.2.0.tar.gz", "has_sig": true, "md5_digest": "e8b584ef1a3b632eb9cd2bfcdadae221", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12927, "upload_time": "2018-01-31T08:49:16", "url": "https://files.pythonhosted.org/packages/d6/c7/c592f0f4102603687ea71ae109277a4069fe9dc3731415da044fe866d5b0/django_postgresql_light_schemas-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "9a498e328b1526d9ae13f1b0dd4e7373", "sha256": "7870ed5812f866c0ba8fa6eb2dc6af2e84b9bedd4e7986ee9de7273884aee19c" }, "downloads": -1, "filename": "django_postgresql_light_schemas-0.2.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "9a498e328b1526d9ae13f1b0dd4e7373", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13096, "upload_time": "2018-02-01T09:06:05", "url": "https://files.pythonhosted.org/packages/66/cc/0bc327b57192647eabbdaaea2a0e9f0878f030457af7c0740474f617ae63/django_postgresql_light_schemas-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1fbe74434082f3619fca05bc069a43f2", "sha256": "a1c1bc5ec87aaf855e645e46e6bd8e724571efc2228a5e0840a7924e729f449f" }, "downloads": -1, "filename": "django_postgresql_light_schemas-0.2.1.tar.gz", "has_sig": true, "md5_digest": "1fbe74434082f3619fca05bc069a43f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12917, "upload_time": "2018-02-01T09:05:56", "url": "https://files.pythonhosted.org/packages/bf/46/6dc2047674cca255ffee1b631aa3dcaa42e2565e5267be8c7e65c8f5db61/django_postgresql_light_schemas-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9a498e328b1526d9ae13f1b0dd4e7373", "sha256": "7870ed5812f866c0ba8fa6eb2dc6af2e84b9bedd4e7986ee9de7273884aee19c" }, "downloads": -1, "filename": "django_postgresql_light_schemas-0.2.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "9a498e328b1526d9ae13f1b0dd4e7373", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13096, "upload_time": "2018-02-01T09:06:05", "url": "https://files.pythonhosted.org/packages/66/cc/0bc327b57192647eabbdaaea2a0e9f0878f030457af7c0740474f617ae63/django_postgresql_light_schemas-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1fbe74434082f3619fca05bc069a43f2", "sha256": "a1c1bc5ec87aaf855e645e46e6bd8e724571efc2228a5e0840a7924e729f449f" }, "downloads": -1, "filename": "django_postgresql_light_schemas-0.2.1.tar.gz", "has_sig": true, "md5_digest": "1fbe74434082f3619fca05bc069a43f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12917, "upload_time": "2018-02-01T09:05:56", "url": "https://files.pythonhosted.org/packages/bf/46/6dc2047674cca255ffee1b631aa3dcaa42e2565e5267be8c7e65c8f5db61/django_postgresql_light_schemas-0.2.1.tar.gz" } ] }