Query Google Sheets Using SQL Via Python - python

I am looking for a way to issue SQL queries to a Google Sheet using Python.
I know that Google Sheets has a function called query that can be used to issue SQL queries from within the spreadsheet itself,
https://support.google.com/docs/answer/3093343?hl=en
Is there some way that I can call this function using Python? Maybe through the gspread module?
I expected there to be a way to call Google Sheets functions (like COUNT, SUM and others) using this package.
I am open to trying other methods as well. Basically, I want to query a Google Sheet like a database using Python.

Related

How to transition from using Google Sheets as a database? (Needs to be manually updated by non tech employees)

I am currently trying to help a small business transition from using Google Sheets as a database to something more robust and scalable - preferably staying within Google services. I've looked into Google Cloud Storage and BigQuery, however - there are employees that need to manually update new data so anything in GCP won't be user friendly for non technical persons. I was thinking of employees still manually updating the Google sheets, and write a Python program to automatically update GCS or BigQuery, but the issue is that Google sheets is extremely slow and cannot handle the amount of data that's currently stored in there now.
Has anyone faced a similar issue and have any ideas/suggestions? Thank you so much in advance :)
What you might be able to do is to save the Google Sheet file as a .csv file and then import it in BigQuery. From there, maybe the employes can use simple commands to insert data. Please note that this question is very opinion based and anyone can suggest various ways to achieve what you want.
Create a web app hosted on App engine for the front end and data entry and connect it to Cloud SQL or BQ as a backend. You can create a UI in your web app where employees can access data from CloudSQL/BQ if needed. Alternatively you can use Google forms for data entry and connect it to Cloud SQL.

Google Sheets API (Python) - What's the equivalent Google API function to Excel VBA's CurrentRegion?

What's the equivalent Google API function to Excel VBA's CurrentRegion? I have multiple tables of data in a single google sheet. At any single instance, I only want to fetch one data table.
VBA's current region provides an easy way to do this in Excel. How may I do the same using Google API Python? Thanks!

Execute python script from within google sheets

What is the easiest way to run a python script from google sheets, or alternatively execute the python script when the google sheets opens?
I'm assuming you have some python asset that you would like to use to modify data on Google Sheets. If that's the case, then I think your best option is to use Google APIs to access Google Sheets from python. You can use any of the following two tutorials by Twilio to achieve that.
If you want to add the python asset into Google sheets (Ex. as a custom function), then it will be much easier to rewrite it in JS.

How can I load data into Google Cloud SQL from Google Big Query?

I have json files flowing in to Google Cloud Storage and then a process setup to flatten them out and load into a table in Google Big Query. I'm wondering if it is possible to setup a sync between the Google Big Query table and a table in Google Cloud SQL so I don't have to write additional code to write the data to two places. Is this possible?
Sorry I mis-read the question. BigQuery supports the API to export to CSV file and Cloud SQL also supports the CSV import, and the default CSV format that bigquery and Cloud SQL uses are compatible.
Original answer: There is no automatic sync setup for this. You need to write a small program to retrieve the data from Cloud SQL and load it to Big Query (https://cloud.google.com/bigquery/loading-data-into-bigquery)

backing up data from app engine datastore as spreadsheet or csv

I am making a survay website on google app engine using Python. For saving the survey form data i am using NDB Datastore. After the survey I have to import it as spreadsheet or CSV. How can i do that.
Thanks.
You need to take a look at the google spreadsheets api, google it, try it, come back when something specific doesnt work.
Also consider using google forms instead which already do what you want (save responses to a spreadsheet)

Categories

Resources