Existing DB without using root user

Hi,
I use a managed PostgreSQL database from a cloud provider and I would like to install ERP Next.
However, I didn’t find a way to install ERPNext without being a root as it fails on query user can’t run and mustn’t run.


File “/home/frappe/frappe-bench/apps/frappe/frappe/database/postgres/setup_db.py”, line 10, in setup_database
root_conn.sql(f"DROP DATABASE IF EXISTS {frappe.conf.db_name}")
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/postgres/database.py”, line 199, in sql
return super().sql(modify_query(query), modify_values(values), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 218, in sql
self._cursor.execute(query, values)
psycopg2.errors.InsufficientPrivilege: must be owner of database erpnext

Error in query:
must be owner of database erpnext

Indeed, it tries to drop database whereas I don’t need that as I provide database. I just would like install script to install everything required in DB without setup of DB itself (drop, create db, create user…).

Any ideas to install Frappe with an empty and already existing DB without root privilege ?

I guess the issue is setup_database: frappe/setup_db.py at develop · frappe/frappe · GitHub

This function shouldn’t run if we don’t need that

You can set your own DB credentials (/users) using --db-root-username and --db-root-password

https://frappeframework.com/docs/v14/user/en/bench/reference/new-site