refactor: remove dead flag db.read_only

This was added in last DB refactor but it does nothing, it was probably
supposed to do something with the connection pool but to best of my
knowledge "read only" is not a property of a connection.

It can be achieved with users who only have read access, that however
isn't implemented anywhere.

Removing this for now.
This commit is contained in:
Ankush Menat 2022-09-08 17:04:06 +05:30
parent f6c548c7b9
commit ea7fbb2c10
3 changed files with 4 additions and 12 deletions

View file

@ -285,9 +285,7 @@ def connect_replica():
user = local.conf.replica_db_name
password = local.conf.replica_db_password
local.replica_db = get_db(
host=local.conf.replica_host, user=user, password=password, port=port, read_only=True
)
local.replica_db = get_db(host=local.conf.replica_host, user=user, password=password, port=port)
# swap db connections
local.primary_db = local.db

View file

@ -39,18 +39,14 @@ def drop_user_and_database(db_name, root_login=None, root_password=None):
)
def get_db(host=None, user=None, password=None, port=None, read_only=False):
def get_db(host=None, user=None, password=None, port=None):
import frappe
if frappe.conf.db_type == "postgres":
import frappe.database.postgres.database
return frappe.database.postgres.database.PostgresDatabase(
host, user, password, port=port, read_only=read_only
)
return frappe.database.postgres.database.PostgresDatabase(host, user, password, port=port)
else:
import frappe.database.mariadb.database
return frappe.database.mariadb.database.MariaDBDatabase(
host, user, password, port=port, read_only=read_only
)
return frappe.database.mariadb.database.MariaDBDatabase(host, user, password, port=port)

View file

@ -83,14 +83,12 @@ class Database:
ac_name=None,
use_default=0,
port=None,
read_only=False,
):
self.setup_type_map()
self.host = host or frappe.conf.db_host or "127.0.0.1"
self.port = port or frappe.conf.db_port or ""
self.user = user or frappe.conf.db_name
self.db_name = frappe.conf.db_name
self.read_only = read_only # Uses READ ONLY connection if set
self._conn = None
if ac_name: