Google BigQuery (and other APIs) from Anvil?

Hi! I’m trying to rebuild (and extend) a working prototype I’ve built in a Jupyter Notebook (actually Google Colab) in Anvil as an interactive app. In Google Colab I use the following approach to authenticate with a GCP service account:

import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/path-to-credentials/credentials-files.json"

And then:

from google.cloud import bigquery

to import the BigQuery library, followed by:

from google.cloud import translate
from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types

For the other libraries I need. I have seen tutorials to call a Jupyter Notebook from Anvil using Uplink, but can I authenticate and call them (most importanty - BigQuery) from Anvil directly?

Thanks!

In a server module, I believe you can do this in principle, but only with the paid version and only if you ask them to install the necessary package.

I don’t know if you can use the BigQuery REST API as an alternative? See: https://anvil.works/docs/http-apis/making-http-requests

Hi @jim

Yes, you can run google.cloud in a Server Module on a paid plan, as long as you’re not also using the Anvil Google integration from the same app (there’s a namespace conflict). Just email us at support@anvil.works and we’ll set your account up to do this.