google-cloud-datastore

How to get the distinct value of one of my models in Google App Engine

偶尔善良 提交于 2019-11-29 10:54:25
I have a model, below, and I would like to get all the distinct area values. The SQL equivalent is select distinct area from tutorials class Tutorials(db.Model): path = db.StringProperty() area = db.StringProperty() sub_area = db.StringProperty() title = db.StringProperty() content = db.BlobProperty() rating = db.RatingProperty() publishedDate = db.DateTimeProperty() published = db.BooleanProperty() I know that in Python I can do a = ['google.com', 'livejournal.com', 'livejournal.com', 'google.com', 'stackoverflow.com'] b = set(a) b >>> set(['livejournal.com', 'google.com', 'stackoverflow.com'

db.ReferenceProperty() vs ndb.KeyProperty in App Engine

依然范特西╮ 提交于 2019-11-29 06:26:57
问题 ReferenceProperty was very helpful in handling references between two modules. Fox example: class UserProf(db.Model): name = db.StringProperty(required=True) class Team(db.Model): manager_name = db.ReferenceProperty(UserProf, collection_name='teams') name = db.StringProperty(required=True) To get 'manager_name' with team instance, we use team_ins.manager_name. To get 'teams' which are managed by particular user instance, we use user_instance.teams and iterate over. Doesn't it look easy and

How do I delete all entities from my local Google App-engine datastore?

懵懂的女人 提交于 2019-11-29 06:05:58
问题 How can I remove all entities or reset the local datastore on my dev_appserver? I accidentally recursively called a function to create an entity when testing. I am using the Google App-engine SDK on Vista with Python. 回答1: dev_appserver.py --clear_datastore=yes myapp See here for more info. Shorthand version: dev_appserver.py -c 回答2: If you came here for a Java solution : Delete the following file: {project root}/WEB-INF/appengine-generated/local_db.bin Rebuild and restart your project. 回答3:

How long (max characters) can a datastore entity key_name be? Is it bad to haver very long key_names?

隐身守侯 提交于 2019-11-29 05:30:42
What is the maximum number of characters that can be used to define the key_name of a datastore entity? Is it bad to have very long key_names? For example: Lets say we use key_names of a 170 characters, which is the length of a Twitter message 140 plus 10 numeric characters for latitude and 10 for longtitude and 10 for a timestamp. (Reasoning of such a key_name: So by using such a key_name we can easily and quickly be sure of no duplicate postings, since the same message should not come from the same place and time more than once.) There's no hard maximum - the maximum length of a key name is

Google App Engine: ImportError: No module named appengine.ext

走远了吗. 提交于 2019-11-29 05:08:49
I am trying to write a test for my GAE programme which uses the datastore. Following Google's Documentation , I see that I should be adding the path to my SDK into my PYTHONPATH. I did this using: import sys sys.path.remove('/usr/local/lib/python2.7/dist-packages') # Has a 'google' module, which I want to be sure isn't interfering. sys.path.insert(1,'/home/olly/google-cloud-sdk/platform/google_appengine') sys.path.insert(1, '/home/olly/google-cloud-sdk/platform/google_appengine/lib/yaml/lib') Then when the file is run: Traceback (most recent call last): File "myapp_tests.py", line 20, in

How do you use list properties in Google App Engine datastore in Java?

蓝咒 提交于 2019-11-29 04:34:20
An object to be placed in the datastore will have a set of tags. public class Model { List<String> tagList ... } In Python, the Google App Engine has the notion of list properties. What is the equivalent notion in Java (if it exists) and how would you use list properties in Java, in JPA and/or in JDO? See my blog post exactly on this: Efficient Keyword Search with Relation Index Entities and Objectify for Google Datastore . It talks about implementing search with list properties using Relation Index Entities and Objectify. To summarize: Query<DocumentKeywords> query = ofy.query

Google App Engine HRD - what if I exceed the 1 write per second limit for writing to the entity group?

拈花ヽ惹草 提交于 2019-11-29 04:22:37
According to the Google App Engine documentation, writing to one entity group is limited to one write per second when using High Replication Datastore. So... What happens if I exceed this limit? Some kind of exception? And what should I do? How do I know that I'm close to exceeding this limit? I can design the application in a way that particular actions (adding an entity...) are not likely to happen often but naturally I can't guarantee that. one write per second is a little low. it actually supports more than that. i would even say between 5 and 10 writes per second but i can't guarantee

Where is my local App Engine datastore?

纵然是瞬间 提交于 2019-11-29 04:03:06
How can I find where my local development datastore is located? I am using the Python SDK and Linux . Sologoub I think it depends on if you got Java or Python SDK. For Python, here's what the instructions say from Google: "The web server prints the location of the datastore file it is using to the terminal when it starts up. You can make a copy of the file, then restore them later to reset the datastore to a known state. Be sure to restart the web server after replacing the datastore file. To change the location used for the datastore file, use the --datastore_path option: dev_appserver.py -

ndb query error with datetime field - Google App Engine

自古美人都是妖i 提交于 2019-11-29 03:57:21
I'm having a problem and I don't find any information about. I define a field in my model like this. class Dates(ndb.model): ... date = ndb.DateTimeProperty(required = True) # I want to store date and time ... Later I try a query (now I want all the dates for a day, I don'tn mind the time): kl = Dates.query(ndb.AND(Dates.date.year == year, Dates.date.month == month, Dates.date.day == day), ancestor = customer.key).fetch(keys_only = True) dates = ndb.get_multi(kl) But I get this error log: AttributeError: 'DateTimeProperty' object has no attribute 'year' I don't know why. I've tried Dates.date(

Dynamically loading Python application code from database under Google App Engine

♀尐吖头ヾ 提交于 2019-11-29 03:31:34
问题 I need to store python code in a database and load it in some kind of bootstrap.py application for execution. I cannot use filesystem because I'm using GAE, so this is my only choice. However I'm not a python experienced user. I already was able to load 1 line of code and run it using eval, however a piece of code with two lines or more gave me a "invalid syntax" error. I'm also thinking if it's possible to extend the "import" loader to implement the DB loading. Thanks! 回答1: I was able to do