Hi, all
  I have a java project on app engine, and I use python based code to
backup my datastore.

jdo
class------------------------------------------------------------------------
public class PaymentUser {
        @PrimaryKey
        private String transId;
        @Persistent
        private String media;
        @Persistent
        private float fee;
        @Persistent
        private String currency;
        @Persistent
        private long timestamp;

        //getters and setter...
}

The backup python
code:---------------------------------------------------------
from google.appengine.ext import db
from google.appengine.tools import bulkloader
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

class PaymentUser(db.Model):
        media = db.StringProperty()
        fee = db.FloatProperty()
        currency = db.StringProperty()
        timestamp = db.IntegerProperty()

def AddKeys(entity_generator):
        for entity in entity_generator:
                entity['key'] = entity.key()
                yield entity

class PaymentUserExporter(bulkloader.Exporter):
        def __init__(self):
                bulkloader.Exporter.__init__(self, 'PaymentUser',
                                                                        
[('transId', str, None),
                                                                         
('media', str, None),
                                                                         
('fee', str, None),
                                                                         
('currency', str, None),
                                                                         
('timestamp', str, None)
                                                                        ])
        def output_entities(self, entity_generator):
                bulkloader.Exporter.output_entities(self, 
AddKeys(entity_generator))
exporters = [PaymentUserExporter]

class PaymentUserLoader(bulkloader.Loader):
        def __init__(self):
                bulkloader.Loader.__init__(self, 'PaymentUser',
                                                                        
[('transId', str),
                                                                         
('media', str),
                                                                         
('fee', float),
                                                                         
('currency', str),
                                                                         
('timestamp', int)
                                                                        ])
loaders = [PaymentUserLoader]

And I use appcfg to  backing up my data to CSV
file.problems:--------------------------------------------------
1.The field currency either some String data or null (not take any
space), because I have to backup these strings,so these nulls are.In
my CSV file these nulls are str "None". When I upload these data to
server again,I found original nulls are replaced by string None.Here I
will waste many spaces.
2. The problem is as same as the first one. But is a long
property(timestamp), when I upload the data to server These None
connot be converted to long value, so there are many exceptions.

How can I solve it, Thanks.

-- 
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