Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dúvida sobre o bd.read_sql #20

Open
lucascunha1979 opened this issue Jun 8, 2021 · 0 comments
Open

dúvida sobre o bd.read_sql #20

lucascunha1979 opened this issue Jun 8, 2021 · 0 comments

Comments

@lucascunha1979
Copy link

oi, tudo bom?

estou com um problema para abrir os arquivos via sql

quando eu rodo um arquivo via bd.read_table tudo funciona certinho, mas quando eu tento via bd.read_sql aparece esse erro aqui (abaixo). é algum problema no "billing_project_id", alguma sugestão do que pode ser?

ah..é sensacional o projeto de vocês

cordialmente

Lucas

    Traceback (most recent call last)

~\Anaconda3\lib\site-packages\pandas_gbq\gbq.py in _download_results(self, query_job, max_results, progress_bar_type)
549
--> 550 query_job.result()
551 # Get the table schema, so that we can list rows.

~\Anaconda3\lib\site-packages\google\cloud\bigquery\job.py in result(self, page_size, max_results, retry, timeout, start_index)
3206 try:
-> 3207 super(QueryJob, self).result(retry=retry, timeout=timeout)
3208

~\Anaconda3\lib\site-packages\google\cloud\bigquery\job.py in result(self, retry, timeout)
811 # TODO: modify PollingFuture so it can pass a retry argument to done().
--> 812 return super(_AsyncJob, self).result(timeout=timeout)
813

~\Anaconda3\lib\site-packages\google\api_core\future\polling.py in result(self, timeout, retry)
133 # Pylint doesn't recognize that this is valid in this case.
--> 134 raise self._exception
135

BadRequest: 400 No matching signature for operator = for argument types: INT64, STRING. Supported signature: ANY = ANY at [4:76]

(job ID: f809e509-5d5c-40a2-aff0-72e03de6d998)

                                         -----Query Job SQL Follows-----                                             

|    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |

1:
2: SELECT estado.uf AS state, estado.municipio AS town, nomes.nome AS name, nomes.qtde_nascimentos_ate_2010 AS freq
3: FROM basedosdados.br_ibge_nomes_brasil.quantidade_municipio_nome_2010 AS nomes
4: INNER JOIN basedosdados.br_bd_diretorios_brasil.municipio AS estado ON nomes.id_municipio = estado.id_municipio
5:
| . | . | . | . | . | . | . | . | . | . | . |

During handling of the above exception, another exception occurred:

GenericGBQException Traceback (most recent call last)
~\Anaconda3\lib\site-packages\basedosdados\download\download.py in read_sql(query, billing_project_id, from_file, reauth)
162 credentials=credentials(from_file=from_file, reauth=reauth),
--> 163 project_id=billing_project_id,
164 )

~\Anaconda3\lib\site-packages\pandas_gbq\gbq.py in read_gbq(query, project_id, index_col, col_order, reauth, auth_local_webserver, dialect, location, configuration, credentials, use_bqstorage_api, max_results, verbose, private_key, progress_bar_type)
966 max_results=max_results,
--> 967 progress_bar_type=progress_bar_type,
968 )

~\Anaconda3\lib\site-packages\pandas_gbq\gbq.py in run_query(self, query, max_results, progress_bar_type, **kwargs)
531 max_results=max_results,
--> 532 progress_bar_type=progress_bar_type,
533 )

~\Anaconda3\lib\site-packages\pandas_gbq\gbq.py in _download_results(self, query_job, max_results, progress_bar_type)
564 except self.http_error as ex:
--> 565 self.process_http_error(ex)
566 finally:

~\Anaconda3\lib\site-packages\pandas_gbq\gbq.py in process_http_error(ex)
432
--> 433 raise GenericGBQException("Reason: {0}".format(ex))
434

GenericGBQException: Reason: 400 No matching signature for operator = for argument types: INT64, STRING. Supported signature: ANY = ANY at [4:76]

(job ID: f809e509-5d5c-40a2-aff0-72e03de6d998)

                                         -----Query Job SQL Follows-----                                             

|    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |

1:
2: SELECT estado.uf AS state, estado.municipio AS town, nomes.nome AS name, nomes.qtde_nascimentos_ate_2010 AS freq
3: FROM basedosdados.br_ibge_nomes_brasil.quantidade_municipio_nome_2010 AS nomes
4: INNER JOIN basedosdados.br_bd_diretorios_brasil.municipio AS estado ON nomes.id_municipio = estado.id_municipio
5:
| . | . | . | . | . | . | . | . | . | . | . |

During handling of the above exception, another exception occurred:

BaseDosDadosException Traceback (most recent call last)
in
5 INNER JOIN basedosdados.br_bd_diretorios_brasil.municipio AS estado ON nomes.id_municipio = estado.id_municipio
6 ''',
----> 7 billing_project_id='level-datum-268001'
8 )

~\Anaconda3\lib\site-packages\basedosdados\download\download.py in read_sql(query, billing_project_id, from_file, reauth)
165 except (OSError, ValueError):
166 raise BaseDosDadosException(
--> 167 "\nWe are not sure which Google Cloud project should be billed.\n"
168 "First, you should make sure that you have a Google Cloud project.\n"
169 "If you don't have one, set one up following these steps: \n"

BaseDosDadosException:
We are not sure which Google Cloud project should be billed.
First, you should make sure that you have a Google Cloud project.
If you don't have one, set one up following these steps:
1. Go to this link https://console.cloud.google.com/projectselector2/home/dashboard
2. Agree with Terms of Service if asked
3. Click in Create Project
4. Put a cool name in your project
5. Hit create
Copy the Project ID, (notice that it is not the Project Name)
Now, you have two options:

  1. Add an argument to your function poiting to the billing project id.
    Like bd.read_table('br_ibge_pib', 'municipios', billing_project_id=<YOUR_PROJECT_ID>)
  2. You can set a project_id in the environment by running the following command in your terminal: gcloud config set project <YOUR_PROJECT_ID>. Bear in mind that you need gcloud installed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant