Google App Engine: Storage Flashcards

1
Q

What are the methods of implementing storage in PaaS?

A
  • Implementing the DB or storage as part of the application
  • Google Datastore
  • Google Cloud Storage
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How could you implement a DB or storage as part of an application?

A

Use a file-based DB (SQLite)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the cons of implementing the DB or storage as part of the application

A

<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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When does implementing the DB or storage as part of the application work?

A

When you only need to read from a database, not write to it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Datastore is a __ database

A

NoSQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a NoSQL database

A
  • Based around objects that contain whatever data fields they want (JSON)
  • Deals with keys&values instead of tables&rows
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why use datastore?

A

You can store data and variables in a persistent manner across all instances

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you fetch from the datastore?

A
  1. Fetch data using a query based on the entity key

2. Store data object in entity and fetch it with the get() function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which database is well suited for storing files?

A

Google Cloud Storage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does Google Cloud Storage work?

A

Uses ‘buckets’ to persistently store and serve files for your application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do we fetch a file from Google Cloud Storage?

A
  1. Create a client object
  2. Fetch bucket using the get_buket() function with bucket ID as a parameter
  3. Fetch a blob of data using get_blob() with the file name as a parameter
  4. Fetch bytes from the blob with a download
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you fetch data from the datastore?

A

Use the client’s get() function to retrieve the entity stored under that key

Returns entity object or none

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The entity returned by the get() function can be handled like a __ or __ in Python

A
  • Dict

- Dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the 2 arguments the key() functions take?

A
  • type

- name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What argument is required to use the get() function?

A

key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you insert entities into Datastore?

A

Use the put() function with the entity as a parameter

17
Q

How do you create an entity?

A

Create an entity using the Entity() function with the key as a parameter

var = datastore.Entity(key=ent)