Question

Django Managed Postgres DB How to access DB. to CREATE SCHEMA

I’ve deployed Django App on APP PLATFORM successfuly. My App requires the setup of Postgres DB Schemas … used with sub-domains in a multi tenancy application. I have setup a Managed Database [production]. How do I access this database so as to CREATE schemas?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I had the same issue deploying django multi tenant solution based on django-tenants. After doing some bit of digging i found out that the db_user created from the control panel have minimal permissions based on DO ‘principle of least privilege’ as defined in the documentation.

To fix this you need to connect to the cluster via psql defaultdb=> propt and grant permissions to your user using the following command GRANT CREATE ON DATABASE <your db> TO <your user>;

More on this you can referce the documentation here https://docs.digitalocean.com/products/databases/postgresql/how-to/modify-user-privileges/

Hi @Softserveapps,

You can go to the database cluster overview page and fetch the Postgres database cluster connection string to connect.

The below links can guide you with connection to Postgres Managed database:

https://docs.digitalocean.com/products/databases/postgresql/how-to/connect/#connect-to-the-database

https://docs.digitalocean.com/products/app-platform/how-to/manage-databases/#connect-to-a-database

I hope this helps!

Regards, Rajkishore