2nd generation Google cloud SQL - App Engine - mysql

Delighted to see that you have rolled out 2nd generation cloud SQL in Beta. However, I see that it is not available yet to GAE projects. Can you estimate when this link will be enabled please? We are making some big infrastructural changes in our fancy system necessitated by the slowness of Generation 1 SQL, but will stick with cloud SQL if the change is not far off.

As of April 27, 2016 Second Generation connectivity to App Engine is supported.
OLD content:
The Cloud SQL team is actively working on adding App Engine support for Second Generation instances. Unfortunately I can't speak about specific dates, but we hope to make it available as soon as possible.

You can now connect to second generation Google Cloud SQL instances from App Engine apps. The connection string is slightly different from first generation instances (docs).
Open your SQL instance in the cloud console.
Under properties copy the "Instance connection name". Note that this is different to the 'name' of your instance and will probably follow the format project:region:instance.
It is normal for the UI to say "None" for authorized applications - you will still be able to connect from GAE. Note: the SQL instance and GAE app must be part of the same project.
Update: Don't have to be in the same project, you need to grant access if they are not in the same project. Ref: https://cloud.google.com/sql/docs/dev-access#gaev1-csqlv2-access
Example PHP connection code:
$con = "mysql:unix_socket=/cloudsql/CONNECTION_STRING_FROM_CONSOLE;dbname=some_db";
$this->db = new pdo($con, "root", "");
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

Related

Can you have two Google Cloud Projects that talk to the same Cloud SQL Database?

I have just created a Project in Google Cloud, and attached a Cloud SQL Database instance to that project. I was able to deploy a Django app that is connected to that DB just fine.
However, I would like to create a separate Django app/Project that is attached to the same Cloud SQL Database that my first Django app is attached to.
Is this possible?
One Django app is responsible for web scraping and supplying constant data to the database while my second Django app (the one I have already deployed) analyzes and returns json on that data. It would be advantageous to separate the two apps because if I ever needed to revise my web scraping algorithm, the whole app would not be down.
You can use cloudsql proxy for both apps. Also as long as you authorize both of your applications with service account that have access to the cloudsql it should be fine.
You can use database that you want, in your current project or in an external one. If you use Cloud SQL proxy, the service account of your app
Either Default AppENgine service account if on App Engine
Or Compute Engine default service account
except is you have defined a specific service account on your component (Cloud Run, Compute engine)
I recommend strongly to use a specific service account on the component if it's possible (not possible with App Engine)
The role to grant on the service account is the following: roles/cloudsql.client
However, I recommend you to smartly think to your design. The current trend is to lock 1 database to 1 service (or microservice).
Think about the schema update: a synchronous update will be required between to 2 services when you update the schema or one, or the other app will fail.
Same thing in case of rollback, both apps need to be rollbacked.
If there is 2 teams, one on each app, their release planning must be sync, and you will lost in velocity and agility.
Maybe, it fits your requirement, or you can duplicate the data, inside the database (other schema). As you wish.

Google Cloud SQL access network

In the Google Cloud console: MySQL-> myInstance-> Connectivity-> Authorized networks
I need to add an IP for my PC. SAVE gives me a message:
Operation failed: Invalid request: disk size can only be set for Second Generation instances..
How can I avoid this error? I didn't change the disk dimension.
I need to do the data export necessary to upgrade MySQL.
I'm 99% sure it's not the version of MySQL that's the issue, it's the version of Cloud SQL instance. See here: https://cloud.google.com/sql/docs/mysql/deprecation-notice for more information about the deprecation of first generation instances. It's still "supported" (ish) until March 2020, but more and more of these kinds of problems are likely to crop up.
As previous folks in the comments said, you should be able to create a ticket to help with the authorized issue to get you past that, but it's just going to be a bandaid. Miguel is right, you will need to transition to a second generation Cloud SQL instance.
Edit: For completeness, Here's the link on how to upgrade your instance that Miguel posted:
https://cloud.google.com/sql/docs/mysql/upgrade-2nd-gen
The first generation is closed and "Connections" cannot be configured. The MySQL generation upgrade has solved the problem.

How to access an existing database file through html5?

I'm working on an desktop app(hta) that need to access information from a database.
My challenge is that already I have the data I need in a sqlite database file. I just want to access this database file from my app then manipulate and display the results to the users.Is it possible to deploy an app like this? I'm not finding a way to access an existing database file through html5.(The sqlite database file will be created during the app installation.It is present in C:\filepath)
The solution will depend on your use case. I can see two of them.
1. Your application runs in disconnected mode (standalone)
HTML5 provides an API called Web SQL Database. It enables you to access an API for storage in the web browser. It's pretty much build around SQLite features. However, all the web browsers do not support it.
2. Your application can access a remote server
In the case you have a remote database, and your application is allowed to access it, I would suggest that you connect to your database by making requests to it. Of course, you will require to develop your own little API on the server side to access the database e.g. via XmlHttpRequest.
You can use javascript to access Web SQL databases. Remember, Web SQL is deprecated and only supported in Chrome and Safari. And Web SQL isn’t even actually part of the HTML5 specification.
For a starter's guide: HTML5 Doctor: Introduction to Web SQL Databases

Pulling data from sqlserver at remote to mysql at local at regular interval

I have a database in sql server that sits in remote machine . I need to pull that data into mysql database on my local machine every 15 min.
I am not much of a technical guy. Please could anyone suggest me easy ways on how can i do this.
you can do in two ways :
Manual way :
you can use sync tools for database like redgate to sync the data .
you can write one windows service which will fetch data from server database and insert all new data into new database every 15 min . you can write windows service in C# using visual studio . you can find some detail of windows service from http://www.aspdotnet-suresh.com/2011/06/creating-windows-service-in-c-or.html .
you can access database from windows services and do some processing on it . you can schedule windows service so that it can execute your script after every 15 min .
You can use Eclipse just fine to write a service/job that would pull data from SQL Server to MySQL.
In Java, you would want to use JDBC to do this.
If you're not a very technical person, my suggestion would be to either learn to do it, or find someone else who knows. What you are requesting is not a simple task. It covers quite a few topics (jobs, scheduling, database connectivity) that you'd need to have some experience with.
You can also check out something like Mule ESB (http://www.mulesoft.org/) which is free. It has some good out of the box functions that can move data from point A to point B.

Wrap SQL Server Objects Quickly?

Back in the MSSQL 2000 timeline, there was an IIS integration layer that allowed HTTP GET commands to make select statements, and there were other SqlXml niceties that worked (not that fast or well but they worked) out of the box. I gave a chance to expose database stuff fairly quickly.
What is the comparable technology for MSSQL 2008/2012? I saw slashDb (http://www.slashdb.com/) and it seems to do that, but I am trying to understand the other options out there. Just SQL Server crud and sproc access.
Thanks.
Yes, SlashDB does exactly that and more. Full disclosure: I am the founder and CEO.
Once SlashDB is installed you would use its web interface to connect it with your database. Depending which database login and database schema you use for that connection, you will have the tables and views from that schema turned into of URL endpoints.
Those URLs can be followed in the browser but they are also API endpoints in JSON, XML or CSV. It works for reading and writing (you can control that in user configuration).
In addition to that you can define a set of parameterized SQL queries. Each query is given a name and instantly becomes an API endpoint too.
In order to help you getting started easily SlashDB is available on AWS and Azure marketplaces, as a Docker container from DockerHub, pre-built virtual machines or as .rpm and .deb packages for installation directly on Linux.
For more technical info please visit: https://docs.slashdb.com
The nearest equivalent may be SOAP/HTTP endpoints, however Microsoft has deprecated them for various reasons and recommends WCF or ASP.NET instead. Although the simplest way to get a quick CRUD setup is probably to use a framework or ORM that generates it for you, like LINQ to SQL or whatever else suits your needs.