Google App Engine: Storage Flashcards
What are the methods of implementing storage in PaaS?
- Implementing the DB or storage as part of the application
- Google Datastore
- Google Cloud Storage
How could you implement a DB or storage as part of an application?
Use a file-based DB (SQLite)
What are the cons of implementing the DB or storage as part of the application
<b>- Persistence</b>
The database starts back at zero every time the application creates a new instance
<b>- Instancing</b>
Cant have a singular database used by all instances since each instance is in its own sandbox
When does implementing the DB or storage as part of the application work?
When you only need to read from a database, not write to it
Datastore is a __ database
NoSQL
What is a NoSQL database
- Based around objects that contain whatever data fields they want (JSON)
- Deals with keys&values instead of tables&rows
Why use datastore?
You can store data and variables in a persistent manner across all instances
How do you fetch from the datastore?
- Fetch data using a query based on the entity key
2. Store data object in entity and fetch it with the get() function
Which database is well suited for storing files?
Google Cloud Storage
How does Google Cloud Storage work?
Uses ‘buckets’ to persistently store and serve files for your application
How do we fetch a file from Google Cloud Storage?
- Create a client object
- Fetch bucket using the get_buket() function with bucket ID as a parameter
- Fetch a blob of data using get_blob() with the file name as a parameter
- Fetch bytes from the blob with a download
How do you fetch data from the datastore?
Use the client’s get() function to retrieve the entity stored under that key
Returns entity object or none
The entity returned by the get() function can be handled like a __ or __ in Python
- Dict
- Dictionary
What are the 2 arguments the key() functions take?
- type
- name
What argument is required to use the get() function?
key