CasJobsUrllib3Client#
- class astropathdb.db_io.dbconnect.CasJobsUrllib3Client#
Bases:
CasJobsTaskExecute queries against CasJobs RESTAPI using
urllib3.We optimize request to allow for use with
urllib3and allow submission of a list of queries to be passed in parallel. This class will keep the connection pool open so that requests do not need a new connection.Danger
As noted throughout this module, this was not designed as a user facing module or as a replacement for the
SciScript-Python.
CasJobsUrllib3Client Attributes#
Shared connection pool so requests reuse open connections. |
CasJobsUrllib3Client Methods#
|
Execute one synchronous SQL query in a |
|
Execute SQL queries in parallel in a |
|
Execute one SQL query, or a sequence of queries in parallel. |
|
Get the |
|
Set the token and 'Accept' in |
|
Format |
CasJobsUrllib3Client References#
Attribute Reference#
- attribute http#
Shared connection pool so requests reuse open connections.
Holds up to 30 connections and blocks when all are in use. ‘Service Unavailable’ (503) responses to POST requests are retried up to 15 times with jittered backoff. Verifies TLS against the operating system’s trust store and the
certifibundle.
Method Reference#
- method execute_query_single(sql, context=CASJOBSDCONST.DEFAULT_DATABASE, _format=CASJOBSDCONST.DEFAULT_RETURNTYPE, *, _futures=False, **_)#
Execute one synchronous SQL query in a
CasJobsdatabase context.Extra keyword arguments, such as
nthreadsforwarded byexecute_query(), are ignored.- Parameters:
sql (str) – The SQL query.
context (str) – The database context.
_format (str) – The output format name. See
query()for the output formats._futures (bool) – Whether the request runs inside
execute_query_futures(). IfTrue, reuses the headers already set and returns the first raw result set dictionary unformatted.
- Returns:
The result sets in the
_formatoutput format.- Raises:
CasJobsRequestError – The request did not complete, for example because retries were exhausted or the connection dropped.
CasJobsConnectionError – The CasJobs API returned an error status.
CasJobsConnectionRefusedError – The CasJobs API refused the authentication token.
- Return type:
dict | list[dict] | tuple[list, list] | DataFrame | list[DataFrame]
See also
SciServer.CasJobs.executeQueryfor theSciScript-Pythonequivalent.
- method execute_query_futures(sql, context=CASJOBSDCONST.DEFAULT_DATABASE, _format=CASJOBSDCONST.DEFAULT_RETURNTYPE, nthreads=CASJOBSDCONST.DEFAULT_THREADS)#
Execute SQL queries in parallel in a
CasJobsdatabase context.Only the first result set of each query is kept. Results are gathered in completion order, not input order.
- Parameters:
- Returns:
The result sets in the
_formatoutput format.- Raises:
CasJobsFuturesConnectionError – One or more queries failed; holds each query’s error.
- Return type:
list[dict] | tuple[list, list] | DataFrame | list[DataFrame]
See also
- method execute_query(sql, *args, **kwargs)#
Execute one SQL query, or a sequence of queries in parallel.
A string runs through
execute_query_single(); any other iterable runs throughexecute_query_futures().
- static get_taskname(task_id)#
Get the
CasJobstask name for a local or SciServer compute client.
Private Method Reference#
- method _validate_response(response)#
Raise if the response status is not ‘OK’ (200).
- Raises:
CasJobsConnectionRefusedError – The token was refused (401) outside a SciServer compute environment.
CasJobsConnectionError – Any other non-200 status.
- Parameters:
response (urllib3.BaseHTTPResponse)
- Return type:
None