Trying to get data from Google Cloud SQL in Flutter - flutter

I'm making a Flutter app with a login page, and I've been trying to query data from a Google Cloud MySQL server and serve it to my app. I was able to replicate the result I want in python using bigquery but I need something like that but in a dart/flutter version(any other ways work too as long as the result is the same)
Any help would be really appreciated!

It is not recommended to connect to the Cloud SQL databases directly over the internet from the client application. So one should avoid connecting to the Cloud SQL database directly from the Flutter Application. In this case, it would be a good idea to create an API endpoint to do the operations in Cloud SQL and hit that endpoint from the Flutter Application.
To achieve the above, we can follow these steps:
Deploy a Http Cloud Functions which connects to the Cloud SQL
database
In this step we have to deploy a Http Cloud Functions and from the Cloud Functions we can connect to the Cloud SQL database. Inside the Cloud Functions we can do the operations on the Cloud SQL database. This document explains how to connect to Cloud SQL from Cloud Functions.
Call the Http Cloud Functions URL from the Flutter Application
After deploying the Cloud Functions, we will get a unique URL for it, which looks like this https://GCP_REGION-PROJECT_ID.cloudfunctions.net/FUNCTION_NAME. We have to call this URL from the Flutter Application. This blog explains how to call the Cloud Functions URL from the Flutter Application.

Related

How to make The Flutter Application online

i have question when someone finish his flutter app with nodjs backend how can i make the application online like when u store queries in DB every body can reach the DB
like firebase but other platforms
I think you are asking how to set up a backend. You can use a server from cloud providers like google cloud platform /AWS /Oracle cloud or you can use a hosting provider like hostinger. Then you can upload your backend (Nodejs) code there.
If you plan to use a cloud prvider like GCP, AWS, Oracle cloud there are free compute machines awailable for startups. At first there is a bit setup to do, which you can easily do by waching a youtube tutorial.

Local Postgres database to Google Cloud PostgreSQL Github

I would like to build a Google Cloud PostgreSQL database using the instructions here
I was able to successfully create the Postgres databases with appropriate tables and views locally.
What do I need to do in order to get the data on Google Cloud PostgreSQL? My goal is to have remote access to this data.
You have 2 options, The first one is use the Cloud SQL proxy as is described here. As the shared links say, the Cloud SQL Proxy provides secure access to your instances without the need for Authorized networks or for configuring SSL.
On the other hand, the second option is only to configure access to your instance under Authorized networks using or not SSL. The complete steps are listed here
You could connect to Cloud SQL from a local test environment using cloud sql proxy. See quickstart-proxy-test.
The workflow is:
Your Application(Running Locally) => cloud sql proxy (Running locally) => GCP remote Cloud SQL service

Google Data Studio JDBC connection to PostgreSQL integration with Sheets?

Google Apps Script JDBC doesn't support a connection to PostgreSQL directly but Google Data Studio supports a connection to PostgreSQL to pull data and build reports. I've also heard they support a low-key export to .csv option. Is it then possible to exploit the Data Studio Service in Google Apps Script to populate Google Sheets with that data, effectively creating a workaround?
All I need is a one-way access from PostgreSQL into Google Sheets by means of Google Apps Script, I do NOT expect to import anything back into my database.
Looking at the reference documentation, the built-in Apps Script service for DataStudio does not allow you to pull data from a connected data source. It can be used to create connectors but its does not allow direct access to connected data sources.
However, you can try creating a custom API or server-less mirco-service in a language that supports PostgreSQL, and then expose that service as HTTP endpoints that you can call via URLFetchApp. You can leverage Google Cloud Functions to do this and write the mirco-service in either back-end Javascript(Node.js), Python or Go. This approach will take you well-outside the bounds of your typical GAS script, but it is a viable option.

How to connect Google Data Studio to Google Cloud SQL

I have a Google Cloud SQL database that I can connect to with my SQL client. However, I have not been able to connect Google Data Studio to the Google Cloud SQL database with the Cloud SQL data source. I have the IP address and credentials from Google Cloud SQL.
My guess is that Google Data Studio cannot connect to Google Cloud SQL because I need to add an IP address to allow the traffic into Google Cloud SQL but Google Data Studio does not have or does not publicize an IP range.
Has anyone had success connecting to Google Cloud SQL using the Cloud SQL data source in Google Data Studio?
The following ranges need to be whitelisted for Data Studio to work:
https://developers.google.com/apps-script/guides/jdbc
Since August 2017, Google Data Studio connects natively to Google Cloud SQL databases:
The current version of the connector no longer requires whitelisting,
and it provides encryption; however, to use these features, you must
create a new data source using the Google Cloud SQL connector.
See Google Cloud SQL connector in help for detailed description on how to create a connector.

Google Cloud Sql usage in external application

Is there a way to use Google Cloud Sql from external application that can't use JDBC, for example from node.js?
You can now use native MySQL connections to access Cloud SQL from just about anything, including, for example, node-db. See:
https://developers.google.com/cloud-sql/docs/access-control
http://nodejsdb.org/