google-cloud-datastore

Google App Engine DB Query Memory Usage

偶尔善良 提交于 2019-11-28 09:45:35
问题 When I run a query on a large set of small objects (15k objects with only a few short string and boolean properties), without doing anything with these objects, I see my instance's memory usage continuously increasing (70Mb increase). The memory increase doesn't look proportional to the amount of data it ever needs to keep in memory for just the query. The loop I use is the following: cursor = None while True: query = MyModel.all() if cursor: query.with_cursor(cursor) fetched = 0 for result

Fetching a random record from the Google App Engine Datastore?

南笙酒味 提交于 2019-11-28 09:42:37
I have a datastore with around 1,000,000 entities in a model. I want to fetch 10 random entities from this. I am not sure how to do this? can someone help? Assign each entity a random number and store it in the entity. Then query for ten records whose random number is greater than (or less than) some other random number. This isn't totally random, however, since entities with nearby random numbers will tend to show up together. If you want to beat this, do ten queries based around ten random numbers, but this will be less efficient. speedplane Jason Hall's answer and the one here aren't

App Engine BadValueError On Bulk Data Upload - TextProperty being construed as StringProperty

倾然丶 夕夏残阳落幕 提交于 2019-11-28 09:30:43
bulkoader.yaml: transformers: - kind: ExampleModel connector: csv property_map: - property: __key__ external_name: key export_transform: transform.key_id_or_name_as_string - property: data external_name: data - property: type external_name: type model.py: class ExampleModel(db.Model): data = db.TextProperty(required=True) type = db.StringProperty(required=True) Everything seems to be fine, yet when I upload I get this error: BadValueError: Property data is 24788 bytes long; it must be 500 or less. Consider Text instead, which can store strings of any length. For some reason, it thinks data is

Revert from Google Cloud Firestore to Datastore

点点圈 提交于 2019-11-28 09:20:23
问题 I signed up for Firebase to use the new Firestore. After trying it out I decided that, for my use cases (mostly server tools) I don't need most of the features of Firestore, that are very much focused on building user interfaces, and I find the old Datastore SDKs nicer for what I'm doing. I know I could simply delete the project and create a new one but I have other things in that project that I would like to keep. Can I revert to Datastore without starting a new project? 回答1: Unfortunately

How to prevent the JSESSIONID showing in the URL [duplicate]

久未见 提交于 2019-11-28 09:16:09
问题 This question already has answers here : How to prevent adding jsessionid at the end of redirected url (1 answer) Is it possible to disable jsessionid in tomcat servlet? (8 answers) Closed 2 years ago . I have created an login page in servlet using Google Datastore, it is working fine. but sometimes its showing the JSESSIONID in the URL. How can I prevent the JSESSIONID sending through the URL? why its passing through the URL instead of request message? 回答1: Add the following entry in your

Store a list of dictionaries in GAE

老子叫甜甜 提交于 2019-11-28 08:49:38
问题 I have a list of about 20 objects and for each object I return a list of 10 dictionaries. I am trying to store the list of 10 dictionaries for each object in the list on GAE; I do not think I am writing the code correctly to store this information to GAE. Here is what I have: Before my main request handler I have this class: class Tw(db.Model): tags = db.ListProperty() ip = db.StringProperty() In my main request handler I have the following: for city in lst_of_cities: # this is the list of 20

Store image to Blobstore from android client and retrieve blobkey and upload url to store in Datastore. - GAE

◇◆丶佛笑我妖孽 提交于 2019-11-28 08:31:54
In my Android application, I want to upload image to the Blobstore, then retrieve an Upload url and the image's Blobkey, so I can store the Blobkey in the DataStore. I've tried this code, but my image isn't uploading: Servlet (Return upload url) BlobstoreService blobstoreService = BlobstoreServiceFactory .getBlobstoreService(); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { UploadOptions uploadOptions = UploadOptions.Builder .withGoogleStorageBucketName("photobucket11") .maxUploadSizeBytes(1048576); String blobUploadUrl = blobstoreService

How to upload data in bulk to the appengine datastore? Older methods do not work

吃可爱长大的小学妹 提交于 2019-11-28 07:36:30
This should be a fairly common requirement, and a simple process: upload data in bulk to the appengine datastore. However, none of the older solutions mentioned on stackoverflow (links below*) seem to work anymore. The bulkloader method, which was the most reasonable solution when uploading to the datastore using the DB API doesn't work with the NDB API And now the bulkloader method seems to have been deprecated and the old links, which are still present in the docs, lead to the wrong page. Here's an example https://developers.google.com/appengine/docs/python/tools/uploadingdata This above

App Engine - why are there PhoneNumber, Link, Rating etc classes?

谁都会走 提交于 2019-11-28 07:16:32
问题 I haven't found any reason for the existence of a few of the App Engine classes. There's a PhoneNumber, a Link, a PostalAddress, a GeoPt, a Rating, etc. Why are these given special treatment? They don't seem to have any smarts - e.g. geo searching. I know Link has more space than a String property, but the rest? See: http://code.google.com/appengine/docs/java/datastore/dataclasses.html 回答1: Those types are 'semantic' types. They're present in the Java API for parity with the Python API. In

Import CSV into google cloud datastore

本小妞迷上赌 提交于 2019-11-28 06:04:05
问题 I have a CSV file with 2 columns and 20,000 rows I would like to import into Google Cloud Datastore. I'm new to the Google Cloud and NoSQL databases. I have tried using dataflow but need to provide a Javascript UDF function name. Does anyone have an example of this? I will be querying this data once it's in the datastore. Any advice or guidance on how to create this would be appreciated. 回答1: Using Apache Beam, you can read a CSV file using the TextIO class. See the TextIO documentation.