Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28774 closed Uncategorized (duplicate)

Use only a specific database schema instead of 'public' one (like in Postgresql)

Reported by: Riccardo Campisano Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords: django, orm, database, postgresql, schema
Cc: riccardo.campisano@…, ogando@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello,

In our project (https://github.com/desihub/qlf) we should use a PostgreSQL database used by others application, so that we want to configure Django ORM to use just a specific schema.

I cannot find such kind of configurations in the official documentation. A tip for a kind of such configuration is available in

https://www.amvtek.com/blog/posts/2014/Jun/13/accessing-multiple-postgres-schemas-from-django/

and it appears to work, using a specific config like that

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'OPTIONS': {
            'options': '-c search_path=qlf_schema'
        },
    },

However, I would be sure that this is the correct (official, supported) way to do such thing, and that will be supported in the future (and that this is not a workaround that currently work but can break in a next version of Django).

Thanks,
Riccardo

Change History (2)

comment:1 by Tim Graham, 7 years ago

Resolution: duplicate
Status: newclosed

Official support for database schemas is discussed in #6148.

I think the '-c search_path=qlf_schema' method you mentioned uses a psycopg2 configuration option and I wouldn't expect that to stop working unless psycopg2 changes it.

comment:2 by Riccardo Campisano, 7 years ago

Thank you for the tip and the link to the discussion.

Riccardo

Note: See TracTickets for help on using tickets.
Back to Top