This method is used to execute query using asynchronous connection. Args: trans_id: unique transaction id
(trans_id)
| 902 | ) |
| 903 | @pga_login_required |
| 904 | def start_view_data(trans_id): |
| 905 | """ |
| 906 | This method is used to execute query using asynchronous connection. |
| 907 | |
| 908 | Args: |
| 909 | trans_id: unique transaction id |
| 910 | """ |
| 911 | limit = -1 |
| 912 | |
| 913 | # Check the transaction and connection status |
| 914 | status, error_msg, conn, trans_obj, session_obj = \ |
| 915 | check_transaction_status(trans_id) |
| 916 | |
| 917 | if error_msg == ERROR_MSG_TRANS_ID_NOT_FOUND: |
| 918 | return make_json_response(success=0, errormsg=error_msg, |
| 919 | info='DATAGRID_TRANSACTION_REQUIRED', |
| 920 | status=404) |
| 921 | |
| 922 | if not status and error_msg and type(error_msg) is Response: |
| 923 | return error_msg |
| 924 | |
| 925 | # Check if connect is passed in the request. |
| 926 | connect = 'connect' in request.args and request.args['connect'] == '1' |
| 927 | |
| 928 | # get the default connection as current connection which is attached to |
| 929 | # trans id holds the cursor which has query result so we cannot use that |
| 930 | # connection to execute another query otherwise we'll lose query result. |
| 931 | |
| 932 | try: |
| 933 | manager = get_driver(PG_DEFAULT_DRIVER).connection_manager( |
| 934 | trans_obj.sid) |
| 935 | default_conn = manager.connection(did=trans_obj.did, |
| 936 | ** ({"database": trans_obj.dbname} |
| 937 | if hasattr(trans_obj, 'dbname') |
| 938 | else {})) |
| 939 | except (ConnectionLost, SSHTunnelConnectionLost) as e: |
| 940 | raise |
| 941 | except Exception as e: |
| 942 | current_app.logger.error(e) |
| 943 | return internal_server_error(errormsg=str(e)) |
| 944 | |
| 945 | # Connect to the Server if not connected. |
| 946 | if not conn.connected() or not default_conn.connected(): |
| 947 | if connect: |
| 948 | # This will check if view/edit data tool connection is lost or not, |
| 949 | # if lost then it will reconnect |
| 950 | status, error_msg, conn, trans_obj, session_obj, response = \ |
| 951 | query_tool_connection_check(trans_id) |
| 952 | # This is required for asking user to enter password |
| 953 | # when password is not saved for the server |
| 954 | if response is not None: |
| 955 | return response |
| 956 | |
| 957 | status, _ = default_conn.connect() |
| 958 | if not status: |
| 959 | return service_unavailable( |
| 960 | gettext("Connection to the server has been lost."), |
| 961 | info="CONNECTION_LOST" |
nothing calls this directly
no test coverage detected