diff --git a/examples/execute_async.py b/examples/execute_async.py index 9c2e9e8..d58dd96 100644 --- a/examples/execute_async.py +++ b/examples/execute_async.py @@ -17,10 +17,10 @@ from railib import api, config, show -def run(database: str, engine: str, command: str, readonly: bool, profile: str): +def run(database: str, engine: str, command: str, language: str, readonly: bool, profile: str): cfg = config.read(profile=profile) ctx = api.Context(**cfg) - rsp = api.exec_async(ctx, database, engine, command, readonly=readonly) + rsp = api.exec_async(ctx, database, engine, command, language, readonly=readonly) print(rsp) show.results(rsp) @@ -30,6 +30,7 @@ def run(database: str, engine: str, command: str, readonly: bool, profile: str): p.add_argument("database", type=str, help="database name") p.add_argument("engine", type=str, help="engine name") p.add_argument("command", type=str, help="rel source string") + p.add_argument("--language", type=str, help="query language") p.add_argument( "--readonly", action="store_true", @@ -39,6 +40,6 @@ def run(database: str, engine: str, command: str, readonly: bool, profile: str): p.add_argument("-p", "--profile", type=str, default="default", help="profile name") args = p.parse_args() try: - run(args.database, args.engine, args.command, args.readonly, args.profile) + run(args.database, args.engine, args.command, args.language, args.readonly, args.profile) except HTTPError as e: show.http_error(e) diff --git a/railib/api.py b/railib/api.py index a369efb..3574401 100644 --- a/railib/api.py +++ b/railib/api.py @@ -578,9 +578,10 @@ def data(self): result["engine_name"] = self.engine return result - def run(self, ctx: Context, command: str, inputs: dict = None) -> Union[dict, list]: + def run(self, ctx: Context, command: str, language: str, inputs: dict = None) -> Union[dict, list]: data = self.data data["query"] = command + data["language"] = language if inputs is not None: inputs = [_query_action_input(k, v) for k, v in inputs.items()] data["v1_inputs"] = inputs @@ -860,11 +861,12 @@ def exec_async( database: str, engine: str, command: str, + language: str = "", readonly: bool = True, inputs: dict = None, ) -> TransactionAsyncResponse: tx = TransactionAsync(database, engine, readonly=readonly) - rsp = tx.run(ctx, command, inputs=inputs) + rsp = tx.run(ctx, command, language=language, inputs=inputs) if isinstance(rsp, dict): return TransactionAsyncResponse(rsp, None, None, None)