Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: How to store an array in Google App Engine datastore

I am working on a project where I process a URL and get an array (containing columns and rows) using beautifulsoup. Now I need to store this data in the datastore. I cannot find any reference on storing an array in the datastore.

like image 365
user2010005 Avatar asked Jul 19 '26 15:07

user2010005


1 Answers

A multivalued property is represented in the datastore api as a python list. If you can organize the data in list, you can define a part of your data model as

class MyData(ndb.Model):
    array = ndb.StringProperty(repeated=True)

In the request handler, store the data like

data = MyData()
data.array = list_you_got_from_request
data.put()
like image 56
Kalle Pokki Avatar answered Jul 21 '26 10:07

Kalle Pokki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!