[REF] Use f-string to make the code lighter
[FIX] execute_psql_command: make optional database argument working correctly [FIX] execute_psql_command: avoid to have an error
This commit is contained in:
parent
284417bb00
commit
8a79974232
|
|
@ -116,19 +116,17 @@ def execute_sql_request(ctx, request, database="postgres"):
|
||||||
|
|
||||||
|
|
||||||
def execute_psql_command(
|
def execute_psql_command(
|
||||||
ctx, request: str, database: str = "postgres", psql_args=None
|
ctx, request: str, database: str = None, psql_args: tuple = ()
|
||||||
):
|
):
|
||||||
"""Execute psql request in postgres container with psql_args on database"""
|
"""Execute psql request in postgres container with psql_args on database"""
|
||||||
if psql_args and not isinstance(psql_args, str):
|
|
||||||
psql_args = " ".join(psql_args)
|
|
||||||
container = get_postgres_container(ctx)
|
container = get_postgres_container(ctx)
|
||||||
command = (
|
command = (
|
||||||
"psql"
|
"psql"
|
||||||
" --username=odoo"
|
" --username=odoo"
|
||||||
" --dbname={database}"
|
f" --dbname={database or 'postgres'}"
|
||||||
' --command "{request}"'
|
f' --command "{request}"'
|
||||||
" {psql_args}"
|
f" {' '.join(psql_args)}"
|
||||||
).format(database=database, request=request, psql_args=psql_args)
|
)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Executing the following command in postgres container\n"
|
"Executing the following command in postgres container\n"
|
||||||
"%s" % (command)
|
"%s" % (command)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user