How to connect local database to Google Cloud SQL? - mysql

Since i am new to Google App Engine, I am using MySQL database locally and I am running a sample application in Google App Engine. But i need to use database also using Google Cloud SQL, I referred some details in the Google developer zone and found some information in connecting Google Cloud SQL using googlemysql connection
I have used a sample code for MySQL connection
if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
// Load the class that provides the new "jdbc:google:mysql://"
// prefix.
Class.forName("com.mysql.jdbc.GoogleDriver");
url = "jdbc:google:mysql://azk-net:your-instance-name/guestbook?user=root";
} else {
// Local MySQL instance to use during development.
Class.forName("com.mysql.jdbc.Driver");
url = "jdbc:mysql://127.0.0.1:3306/guestbook?user=root";
// Alternatively, connect to a Google Cloud SQL instance using:
// jdbc:mysql://ip-address-of-google-cloud-sql-instance:3306/guestbook?user=root
}
but the thing is i cannot create instance name for my project. In local it is working correctly but i have deployed in the google app engine i am getting error since instance name is not available
I am creating the instance name in the Google Cloud SQL but it is not creating it requires billing.
can anyone help me to connect the database from local to Google Cloud SQL by writing connection properties for accessing database from Google Cloud SQL.

There's no free quota for Google Cloud SQL, you have to enable billing to use it
Google offers two billing plans for Cloud SQL: Packages and Per Use. More information on pricing for Google Cloud SQL can be found on the Cloud SQL Pricing page.

Related

API Base URL for Google Cloud SQL

I am trying to integrate Google Cloud SQL for Mysql into another application. The other application wants the "api base url". Does anyone know how to get the "api base url" of Google Cloud SQL for Mysql?
If you are using Google Cloud SQL and you are trying to connect your external application this documentation is the best for your case. In that document discuss the summary of connection options, authorization options and code samples also the tools for connecting that will help you to connect in Cloud SQL Mysql instance.
If you are referring to the reference of REST APIs of Cloud SQL and its service-endpoint(https://www.googleapis.com), these are some examples:
Method
Format
Description
delete
DELETE /sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}
Deletes a database from a Cloud SQL instance.
get
GET /sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}
Retrieves a resource containing information about a database inside a Cloud SQL instance.
insert
POST /sql/v1beta4/projects/{project}/instances/{instance}/databases
Inserts a resource containing information about a database inside a Cloud SQL instance.
update
PUT /sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}
Updates a resource containing information about a database inside a Cloud SQL instance.
NOTE: You need to enable the Cloud SQL Admin API before using it.

How to Authorise circle-ci with Google Cloud SQL instance

I have NodeJS applications which utilise the SQL instance from Google App Engine. I have created a continuous integration (CI) deployment environment with CircleCI and Google App Engine. The deployment works nice. Now, I want to execute my unit tests on CircleCi. But the problem is how do I connect Google Cloud SQL instance on CircleCI?
On the local system, I use Google Cloud SQL proxy OR SSL connection to establish a connection with MySQL. How do I connect to Google Cloud SQL instance from circle-ci using NodeJs MySQL package?

Google App maker API

I have a requirement to pull and post data to another application. App maker provides URL fetch option to get data from public API's.
I want to access data from a application in my intranet server does app maker provides any option to connect to the outside server.
URL Fetch option is used to consume data, if I need to pass some data is there any option available to do this in app script
I have a requirement to pull and post data to another application
If you don't have strong requirements on a way how to pull/post the data you can consider sharing data via database:
Option one: shared database
You can connect App Maker and your other apps to the same Google Cloud SQL database
Option two: direct database connection
Let's say, you have App Maker app connected to Google Cloud SQL database and some internal apps connected to your internal databases. From App Maker side you can connect to your internal databases using JDBC service and you can whitelist your internal apps to connect to your Cloud SQL instance that App Maker app is connected to.
Option three: API way
At this time App Maker app cannot serve as API endpoint(How to create a rest api in app maker?)
But in theory it should work fine with third party services(External API)

Cannot access Google Cloud SQL database from my App Engine

Last week I tried to setup Google Cloud for a NodeJS API and Cloud SQL database. Overall it works fine, but I can't access my Cloud SQL database. The authorization of the SQL database shows that all apps within the current project are granted to access the database. Unfortunality, this is not true. I need to granted the IP addresses of the instances from the App Engine. The IP adressess of the instances constantly changes after I deploy a newer version of the the API.
Does anybody have a solution to get access from the App Engine to the Cloud SQL database. It's very annoying to add constant the instance ip address to grant the database.
Sample here
Thank you in advance!
Jelle
I was going to suggest to assign a static IP to the app engine, but seems like it's not possible in App engine (it's possible in compute engine though). So lets tackle the root of the problem, you being unable to access cloud sql from App engine, are you sure you followed the instructions of the following link to the letter?
https://cloud.google.com/nodejs/getting-started/using-cloud-sql
This might solve your connection issue if you haven't.

google app engine denying google sql connection

I am trying to connect my web application to google sql. The app is running and getting deployed on appspot without database access. However when I try to deploy enable google cloud sql it is giving me following error:
I am to access the cloud sql using mysql command line prompt. Can anybody help what am I doing wrong here. I think there is a problem with appid. I create an application name cfsdonuts on appengine and gave it the access to sql instance. I create the application on eclipse with same appid (because eclipse was not allowing to choose from existing id's not it was allowing me to create new app id at the time of project creation. When I deploy the application on app engine the name comes as http://1-dot-cfsdonuts.appspot.com/. Should I use this name?