Hi all,
I'm trying to write a GQL query that returns N random records of a specific kind. My current implementation works but requires N calls to the datastore. I'd like to make it 1 call to the datastore if possible.
I currently assign a random number to every kind that I put into the datastore. When I query for a random record I gen...
From the GAE getting started guide
Because the App Engine datastore is
not a traditional relational database,
queries are not specified using SQL.
Instead, you can prepare queries using
a SQL-like query language we call GQL.
What do they mean by "not a traditional relational database" and what implications does this have ot...
I have a Course entity which contains a Set of Keys to my Tag entity. How would I go about creating a query to get a list of courses with a specific tag? For example, I want to find all the courses tagged with java.
Here are my entities:
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class Cou...
In reference to this different but not unrelated question I will borrow the example models.
class Foo(db.Model): bars = db.ListProperty(db.Key)
class Bar(db.Model): pass
If I have a certain Foo entity and I want to get all of the other foo entities also containing a certain bar Key in its bars ListProperty, I would use the following...
class Message(db.Model):
user = db.ReferenceProperty(User, required=True, collection_name='Message_set')
text = db.TextProperty(required=True)
I tried this but I'm getting BadValueError on the gql statement.
users = []
users.append(userA)
users.append(userB)
users.append(userC)
messages = Message.gql('Where user In :users', use...
I'm having a hard time trying to reset my ID/Name column in my google app. Right now it's on 3002, yet there's only 1 other peice of data still in the DB. I'm not even certain how it decided on 300x over like 1,2,3...
I'm sure this is a simple problem for someone more SQL inclined than I am :).
Thanks in advance!
...
I'm trying to query records in Google App engine where an IntegerProperty is null (None). This is what I tried without success:
data = db.GqlQuery("SELECT * FROM MyModel WHERE intProp=:1",None)
And also with a Query:
query = db.Query(MyModel)
query = query.filter('intProp', None)
data = query.fetch(limit=100)
Any help would be app...
Okay so I have this mode:
class Posts(db.Model):
rand1 = db.FloatProperty()
#other models here
and this controller:
class Random(webapp.RequestHandler):
def get(self):
rand2 = random.random()
posts_query = db.GqlQuery("SELECT * FROM Posts WHERE rand1 > :rand2 ORDER BY rand LIMIT 1")
#Assigning values for Django templa...
I have this datastore model
class Project(db.Model)
projectname = db.StringProperty()
projecturl = db.StringProperty()
class Task(db.Model)
project = db.ReferenceProperty(Project)
taskname= db.StringProperty()
taskdesc = db.StringProperty()
How do I edit the value of taskname ? say I have task1 and i want to change it to task1-project...
How do I know if the results of my query either using the Query interface or the GqlQuery interface returned zero results? Would using .get() on zero results produce an error? If yes, what's the best way to handle it?
...
What would be the App Engine equivalent of this Django statement?
return Post.objects.get(created_at__year=bits[0],
created_at__month=bits[1],
created_at__day=bits[2],
slug__iexact=bits[3])
I've ended up writing this:
Post.gql('WHERE created_at > DATE(:1, :2, :3) AND created_at < DATE(:1, :2, :4) and slug = :5'...
Using the google appengine datastore, is there a way to perform a gql query that specifies a WHERE clause on a StringProperty datatype that is case insensitive? I am not always sure what case the value will be in. The docs specify that the where is case sensitive for my values, is there a way to make this insensitive?
for instance the...
Hello,
I am after a Python module for Google App Engine that abstracts away limitations of the GQL.
Specifically I want to store big files (> 1MB) and retrieve all records for a model (> 1000). I have my own code that handles this at present but would prefer to build on existing work, if available.
Thanks
...
Hi,
I am able to properly pass a string variable to the gqlquery through parameter substitution, here's the code i've tried to use;
user_name = self.request.get('username') #retrieved from UI
p = models.UserDetails.all().filter('user_name = ', user_name).fetch(1)
I don't get any results and the query fails silently. But when I hard c...
I just noticed a strange result from a query that I have trouble understanding. It appears as if adding an order() to a Query is limiting the results I get back.
Here is my interaction:
>>> SomeModel.all().filter('action =', 'foo').order('created_at').count(),
SomeModel.all().filter('action =', 'foo').count()
(192L, 293L)
>>> Some...
I need to filter entities based on one of their ListProperties having a certain element present. So kind of like:
entities.filter('listProp IN ',element) except where listProp and element are reversed if you see what I mean.
Anyone know how to filter like this?
...
Is there a way to convert the GqlQuery object to an array of keys, or is there a way to force the query to return an array of keys? For example:
items = db.GqlQuery("SELECT __key__ FROM Items")
returns an object containing the keys:
<google.appengine.ext.db.GqlQuery object at 0x0415E210>
I need to compare it to an array of keys t...
I want to do an OR filter within google app engine.
For example:
class MyModel(db.Model):
name = db.StringPropery()
description = db. StringPropery()
The following will return all "MyModel" instances with name = steve AND description = "some text"
results = MyModel.all().filter("name =", "steve").filter("description =","some...
How do I apply a GQL query such that it lists the user_name in the UserInformation model table of those who have logged in within the last 3 days?
...
I have the following model of Users and I want to get all the users that like 'yellow', but don't like 'red'.
class User(db.Model):
name = db.StringProperty(required=True)
favorite_colors = db.StringListProperty(required=True)
This works (all users that have at least one favorite color 'yellow' are returned):
results = db.Gql...