Beispiel #1
0
def get_databases(service, session_handle):
    req = TGetSchemasReq(sessionHandle=session_handle, schemaName='.*')
    log.debug('get_databases: req=%s', req)
    resp = service.GetSchemas(req)
    log.debug('get_databases: resp=%s', resp)
    err_if_rpc_not_ok(resp)
    return resp.operationHandle
Beispiel #2
0
def database_exists(service, session_handle, hs2_protocol_version, db_name):
    req = TGetSchemasReq(sessionHandle=session_handle, schemaName=db_name)
    log.debug('database_exists: req=%s', req)
    resp = service.GetSchemas(req)
    log.debug('database_exists: resp=%s', resp)
    err_if_rpc_not_ok(resp)
    operation_handle = resp.operationHandle
    # this only fetches default max_rows, but there should only be one row
    # ideally
    results = fetch_results(service=service,
                            operation_handle=operation_handle,
                            hs2_protocol_version=hs2_protocol_version)
    exists = False
    for result in results:
        if result[0].lower() == db_name.lower():
            exists = True
    close_operation(service, operation_handle)
    return exists
Beispiel #3
0
 def get_databases(self, schema='.*'):
     req = TGetSchemasReq(sessionHandle=self.handle, schemaName=schema)
     return self._operation('GetSchemas', req)