📜 ⬆️ ⬇️

Django application support in Google App Engine

Recently google announced Cloud SQL for its cloud. But at first there was no support for django, and in early February App Engine 1.6.2 comes out with support for launching applications on django. Now you can forget about jumping around the app-engine-patch and django-nonre, and try to emulate a relational database on top of a bigtable.

They give us django 1.2 and the module for working with Cloud SQL out of the box, and we can forget about crutches with packaging packages in zip archives. Here are the steps we need to take to get a simple application in the cloud:
  1. First you need to request test access to Cloud SQL through the Google APIs Console . I was given access for 3 days, then in the console we will get access to service management.

  2. After gaining access, we are essentially given the usual access to executing mysql console commands, where we can create a database.

  3. Now we create a normal GAE application within which there will be a django + app.yaml web application in which you need to register:
    application: appname version: 1 runtime: python27 api_version: 1 threadsafe: true libraries: - name: django version: "1.2" builtins: - django_wsgi: on 

  4. In order for the django application to be able to access Cloud SQL, it is only necessary to register in the config for DATABASES:
     DATABASES = { 'default': { 'ENGINE': 'google.appengine.ext.django.backends.rdbms', 'INSTANCE': 'my_project:instance1', 'NAME': 'my_database', } } 


This is the main thing you need to do to prepare the application. When you first try to make syncdb, we will be asked to log in, to do this, you need to get the token through the Google APIs Console on the API Access tab, and how the instruction says to place it in ~/.googlesql_oauth2.dat (for windows %USERPROFILE%\.googlesql_oauth2.dat ) . During syncdb in Cloud SQL, create the necessary database schema for the application and load the fixtures if there are any. While the development is on the local machine, the application works with the sqlite3 database. After that, you can safely push the application to the cloud.

IMHO


I believe that Google made the right move, giving the SQL database. They could not shoot with their cloud. Yes, at the time it looked interesting, but everyone quickly realized that it was too limited, and it would be very difficult to transfer the application to google services. Yes, there are tools for migrating to Amazon services, but they do not provide guarantees, and in any case, an N-th number of man hours will be required for the transfer. I do not remember not one large site working on top of GAE, there was an interesting online store project , but that one is more dead than alive. Large projects rather avoid GAE or even don’t think about it when there is an Amazon on which to build their architecture, it is easy to migrate if necessary.
For those who need something smaller, it is too difficult to start a blogger, a business card site, etc. And why do we need to understand the features of development under GAE, when you can run this on specialized services without much effort.
But with the launch of Cloud SQL, the situation may change a little. Now you can safely run django sites of average complexity on GAE, tie the domain to it, and forget about server administration. Just do not forget about the fact that GAE supports libraries written only in pure python, all modules should be forgotten, as well as restrictions on http requests from the application. And we still need to use the GAE API to upload files to the repository, sending email and caching to memcache, but even with these limitations, this will cover most of the needs for deploying “simple” sites.

References:

')

Source: https://habr.com/ru/post/139354/


All Articles