You can do this now using the RemoteDatastore Java utility

http://code.google.com/p/remote-datastore/

For example, this code runs on your desktop and creates a single entity in your live datastore:

   // divert datastore operations to live application
   RemoteDatastore.install();
RemoteDatastore.divert("http://myVersion.latest.myApp.appspot.com/remote-datastore ", "myApp", "myVersion");

   // create an entity with a numeric key
   Key key = KeyFactory.createKey("MyKindName, 35);
   Entity entity1 = new Entity(key);
   entity1.setProperty("property1", "hello");

   // put entity to the remote datastore
DatastoreService service = DatastoreServiceFactory.getDatastoreService();
   datastore.put(entity1);

This also works for bulk puts

On 14 Jul 2010, at 03:37, Matthew Blain wrote:

Sorry, this won't be available until 1.3.6. You should be able to do
something like this:

- property: __key__
  external_name: CityId
  export_transform: datastore.Key.id
  import_transform: lambda value: datastore.Key.from_path('City',
int(value))


--Matthew

On Jul 10, 5:53 pm, Pasha <pavel.selivers...@gmail.com> wrote:
Could you please post an example. Thank you in advance.

On Jun 30, 1:18 pm, Matthew Blain <matthew.bl...@google.com> wrote:



The 1.3.5 bulkloader client will allow you to specify a numeric key;
you must use the Key constructor explicitly to do this, integers will
still be converted into strings.

On Jun 30, 12:12 am, MANISH DHIMAN <manisd...@gmail.com> wrote:

Hi All
When I upload data using CSV file on G A E. Primary key is stored
there as a name instead of id.
Example.

Format of .yaml is Given below
transformers:
- kind: City
  connector: csv
  connector_options:
    encoding: utf-8
    columns: from_header
  property_map:
    - property: __key__
      external_name: CityId
      export_transform: datastore.Key.id
    - property: Name
      external_name: Name

Primary key stored there is:
ID/Name                   Name
name=1                    Delhi
name=2                    London

Due to uploaded data with name=<keyvalue>, when I am try to get Key
from any Fetched Entities, then Key contains only name value but id
value is 0 and also name contains long value as a String instance.

Is it possible to store primary key(Using CSV while uploading data) in
a format given below :
ID/Name              Name
id=1                    Delhi
id=2                    London

When data is stored with id=<keyvalue>, then Key contains id value is
<keyvalue> as long instance.

--
You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-java@googlegroups.com . To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en .


--
You received this message because you are subscribed to the Google Groups "Google 
App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to