Skip to content

Commit

Permalink
fix: log psql console usage as well (backport #25417) (#25423)
Browse files Browse the repository at this point in the history
* fix: log psql console usage as well

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
(cherry picked from commit afdb455)

* refactor: move histfile setting into helper function

This will ensure even users of `bench db-console` can use it

(cherry picked from commit d0923b0)
Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Co-authored-by: Akhil Narang <me@akhilnarang.dev>
  • Loading branch information
mergify[bot] and akhilnarang committed Mar 15, 2024
1 parent 21e1280 commit f0fa5d1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frappe/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,8 @@ def mariadb(context, extra_args):
"""
Enter into mariadb console for a given site.
"""
from frappe.utils import get_site_path

site = get_site(context)
frappe.init(site=site)
os.environ["MYSQL_HISTFILE"] = os.path.abspath(get_site_path("logs", "mariadb_console.log"))
frappe.conf.db_type = "mariadb"
_enter_console(extra_args=extra_args)

Expand All @@ -500,6 +497,12 @@ def postgres(context, extra_args):

def _enter_console(extra_args=None):
from frappe.database import get_command
from frappe.utils import get_site_path

if frappe.conf.db_type == "mariadb":
os.environ["MYSQL_HISTFILE"] = os.path.abspath(get_site_path("logs", "mariadb_console.log"))
else:
os.environ["PSQL_HISTORY"] = os.path.abspath(get_site_path("logs", "postgresql_console.log"))

bin, args, bin_name = get_command(
host=frappe.conf.db_host,
Expand Down

0 comments on commit f0fa5d1

Please sign in to comment.