mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-13 10:30:16 +00:00
Closes: #2538 Tests: - Without the patch, set the Zoph CLI User to "autodetect" and notice the failure to load Zoph page. - With the patch, set user to "autodetect" and access the app page. It is updated to the first admin user in Zoph DB. - Try with updating Zoph configuration. - Try with re-running Zoph setup. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
18 lines
528 B
Python
18 lines
528 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
|
|
|
|
|
|
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 subprocess.run(
|
|
['mysql', '--user=root', '--database', database_name],
|
|
input=query.encode('utf-8'), check=True)
|