简体   繁体   中英

Appengine - Storing a Pickled in Datastore

In Google Appengine, I'm interested in pickling an object and storing it in the datastore. I don't need to index it.

Is there any difference if I store it as a BlobProperty or TextProperty? Which one is better?

BlobProperty can store binary data while TextProperty can store only strings .

You can use BlobProperty as TextProperty is basicly a BlobProperty with encoding.

NDB now offers: PickleProperty .

Value is a Python object (such as a list or a dict or a string) that is serializable using Python's pickle protocol; the Datastore stores the pickle serialization as a blob. Unindexed by default.

Optional keyword argument: compressed .

Never mind. I just ran tests with both. It appears that you cannot use TextProperty with pickle. It will cause errors. Using it with BlobProperty, on the other hand, works perfectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM