Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Python for Google App Engine
  • Toc
  • feedback
Python for Google App Engine

Python for Google App Engine

By : Pippi
4.1 (10)
close
Python for Google App Engine

Python for Google App Engine

4.1 (10)
By: Pippi

Overview of this book

If you are a Python developer, whether you have experience in web applications development or not, and want to rapidly deploy a scalable backend service or a modern web application on Google App Engine, then this book is for you.
Table of Contents (10 chapters)
close
9
Index

Loading and saving data

Now that we know how to connect to a Cloud SQL instance from our App Engine application, it's time to learn how to write and read data from the database. We already created a table called ops, and we will use it to store information about user operations. We will log the following events:

  • A user has created a note
  • A user has added a file
  • A user has performed a shrink operation

We have to assign a text code to each of the operation types we want to log. To do so, we can use a simple Python class that works as an enumeration. In the utils.py module, we add the following code:

class OpTypes(object):
    NOTE_CREATED = 'NCREATED'
    FILE_ADDED = 'FADDED'
    SHRINK_PERFORMED = 'SHRINKED'

We will see how to use it in a moment. We now provide a log_operation() method in the utils.py module that we will use to log operations in the Cloud SQL database. We will call this function within the Notes code passing along the user who actually performed...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete