by
db.put([k1, k2, k3]])
index.yaml
SELECT * FROM Person WHERE birth_year >= 1970 ORDER BY last_name # ERROR SELECT * FROM Person WHERE birth_year >= 1970 ORDER BY last_name, birth_year # ERROR SELECT * FROM Person WHERE birth_year >= 1970 ORDER BY birth_year, last_name #OK
parent=x
attribute on creation of the entity.
employee = Employee() #a db.Model employee.put() # Create an Address in the same entity group as the Employee by setting # the Employee as the Address's parent. address = Address(parent=employee) # Another way...using the db.Key of the Employee. e_key = employee.key() address = Address(parent=e_key)
class Person(db.Expando): first_name = db.StringProperty() last_name = db.StringProperty() hobbies = db.StringListProperty() p = Person(first_name="Albert", last_name="Johnson") p.hobbies = ["chess", "travel"] p.chess_elo_rating = 1350 p.travel_countries_visited = ["Spain", "Italy", "USA", "Brazil"] p.travel_trip_count = 13
from google.appengine.ext import db from google.appengine.ext.db import polymodel class Contact(polymodel.PolyModel): phone_number = db.PhoneNumberProperty() address = db.PostalAddressProperty() class Person(Contact): first_name = db.StringProperty() last_name = db.StringProperty() mobile_number = db.PhoneNumberProperty() class Company(Contact): name = db.StringProperty() fax_number = db.PhoneNumberProperty()
Master/Slave | High Replication | |
---|---|---|
Cost | ||
Storage | 1x | 3x |
Put/Delete CPU | 1x | 3x |
Get CPU | 1x | 1x |
Query CPU | 1x | 1x |
Performance | ||
Put/Delete Latency | 1x | 1x–2x |
Get Latency | 1x | 1x |
Query Latency | 1x | 1x |
Consistency | ||
Get/Put/Delete | Strong | Strong |
Most Queries | Strong | Eventual |
Ancestor Queries | Strong | Strong |
Occasional Planned Read-Only Period | Yes | No |
Unplanned Downtime | Rare. Possible to lose a small % of writes that occurred near the downtime (recoverable after event). | Extremely rare. No data loss. |
Model | Kind |
---|---|
google.appengine.ext.db.metadata.Namespace | __namespace__ |
google.appengine.ext.db.metadata.Kind | __kind__ |
google.appengine.ext.db.metadata.Property | __property__ |
import google.appengine.ext.db from google.appengine.ext.db.metadata import Kind q = Kind.all() q.filter('__key__ >=', Kind.key_for_kind('a')) q.filter('__key__ <', Kind.key_for_kind(chr(ord('z') + 1))) for kind in q.fetch(100): print kind.kind_name