How to use the pybigquery.parse_url.parse_url function in pybigquery

To help you get started, we’ve selected a few pybigquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mxmzdlv / pybigquery / test / test_parse_url.py View on Github external
def test_only_dataset():
    url = parse_url(make_url('bigquery:///some-dataset'))
    project_id, location, dataset_id, arraysize, credentials_path, job_config = url

    assert project_id is None
    assert location is None
    assert dataset_id == 'some-dataset'
    assert arraysize is None
    assert credentials_path is None
    assert isinstance(job_config, QueryJobConfig)
    # we can't actually test that the dataset is on the job_config,
github mxmzdlv / pybigquery / test / test_parse_url.py View on Github external
def test_empty_with_non_config():
    url = parse_url(make_url('bigquery:///?location=some-location&arraysize=1000&credentials_path=/some/path/to.json'))
    project_id, location, dataset_id, arraysize, credentials_path, job_config = url

    assert project_id is None
    assert location == 'some-location'
    assert dataset_id is None
    assert arraysize == 1000
    assert credentials_path == '/some/path/to.json'
    assert job_config is None
github mxmzdlv / pybigquery / test / test_parse_url.py View on Github external
def test_not_implemented(not_implemented_arg):
    url = make_url('bigquery://some-project/some-dataset/?' + not_implemented_arg + '=' + 'whatever')
    with pytest.raises(NotImplementedError):
        parse_url(url)
github mxmzdlv / pybigquery / test / test_parse_url.py View on Github external
def test_bad_values(param, value):
    url = make_url('bigquery:///?' + param + '=' + value)
    with pytest.raises(ValueError):
        parse_url(url)
github mxmzdlv / pybigquery / test / test_parse_url.py View on Github external
def test_empty_url():
    for value in parse_url(make_url('bigquery://')):
        assert value is None

    for value in parse_url(make_url('bigquery:///')):
        assert value is None
github mxmzdlv / pybigquery / test / test_parse_url.py View on Github external
def test_basic(url_with_everything):
    project_id, location, dataset_id, arraysize, credentials_path, job_config = parse_url(url_with_everything)

    assert project_id == 'some-project'
    assert location == 'some-location'
    assert dataset_id == 'some-dataset'
    assert arraysize == 1000
    assert credentials_path == '/some/path/to.json'
    assert isinstance(job_config, QueryJobConfig)
github mxmzdlv / pybigquery / test / test_parse_url.py View on Github external
def test_disallowed(disallowed_arg):
    url = make_url('bigquery://some-project/some-dataset/?' + disallowed_arg + '=' + 'whatever')
    with pytest.raises(ValueError):
        parse_url(url)
github mxmzdlv / pybigquery / test / test_parse_url.py View on Github external
def test_all_values(url_with_everything, param, value):
    job_config = parse_url(url_with_everything)[5]

    config_value = getattr(job_config, param)
    if callable(value):
        assert value(config_value)
    else:
        assert config_value == value
github mxmzdlv / pybigquery / pybigquery / sqlalchemy_bigquery.py View on Github external
def create_connect_args(self, url):
        project_id, location, dataset_id, arraysize, credentials_path, default_query_job_config = parse_url(url)

        self.arraysize = self.arraysize or arraysize
        self.location = location or self.location
        self.credentials_path = credentials_path or self.credentials_path
        self.dataset_id = dataset_id

        if self.credentials_path:
            credentials = service_account.Credentials.from_service_account_file(self.credentials_path)
            client = self._create_client_from_credentials(credentials, default_query_job_config, project_id)

        elif self.credentials_info:
            credentials = service_account.Credentials.from_service_account_info(self.credentials_info)
            client = self._create_client_from_credentials(credentials, default_query_job_config, project_id)

        else:
            self._add_default_dataset_to_job_config(default_query_job_config, project_id, dataset_id)