mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
- This is to capture stdout and stderr and transmit that from privileged daemon back to the service to be displayed in HTML. Tests: - Unit tests and code checks pass. - Some of the modified actions work as expected. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
20 lines
559 B
Python
20 lines
559 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Utilities to help with MariaDB/MySQL databases.
|
|
|
|
Uses utilities from 'mysql-client' package such as 'mysql' and 'mysqldump'.
|
|
"""
|
|
|
|
import subprocess
|
|
|
|
from .. import action_utils
|
|
|
|
|
|
def run_query(database_name: str, query: str) -> subprocess.CompletedProcess:
|
|
"""Run a database query using 'root' user.
|
|
|
|
Does not ensure that the database server is running.
|
|
"""
|
|
return action_utils.run(
|
|
['mysql', '--user=root', '--database', database_name],
|
|
input=query.encode('utf-8'), check=True)
|