我知道这在GAE帮助网站上有很多内容。这对我不起作用。我在Python上有点绿色。但我也知道进口是如何运作的。实体模块与加载器位于同一文件夹中。那么GAE脚本在做什么呢?
这是我的装载机:
from google.appengine.ext import db
from google.appengine.tools import bulkloader
import entities
class CardLoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'Card',
[('english', str),
('translation', str)
])
loaders = [CardLoader]
以下是名为entities.py
的文件from google.appengine.ext import db
class Card(db.Model):
english = db.StringProperty(required=True)
translation = db.StringProperty(required=True)
以下是.csv
中的内容"cardId","english","translation"
"3994","face","la cara"
"4027","art","el arte"
我的Python版本:
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
这是我的命令(在Windows上):
python“c:\ Program Files \ Google \ google_appengine \ appcfg.py” upload_data --config_file = card_loader.py --url http://localhost:8080/remote_api --filename = card_data.csv --kind = Card
这是输出:
Uploading data records.
[INFO ] Logging to bulkloader-log-20110723.183520
[INFO ] Throttling transfers:
[INFO ] Bandwidth: 250000 bytes/second
[INFO ] HTTP connections: 8/second
[INFO ] Entities inserted/fetched/modified: 20/second
[INFO ] Batch Size: 10
Please enter login credentials for localhost:8080
Email: admin
Password for admin:
Traceback (most recent call last):
File "c:\Program Files\Google\google_appengine\appcfg.py", line 76, in <module
>
run_file(__file__, globals())
File "c:\Program Files\Google\google_appengine\appcfg.py", line 72, in run_fil
e
execfile(script_path, globals_)
File "c:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 3708, in <module>
main(sys.argv)
File "c:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 3699, in main
result = AppCfgApp(argv).Run()
File "c:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 2345, in Run
self.action(self)
File "c:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 3484, in __call__
return method()
File "c:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 3311, in PerformUpload
run_fn(args)
File "c:\Program Files\Google\google_appengine\google\appengine\tools\appcfg.p
y", line 3202, in RunBulkloader
sys.exit(bulkloader.Run(arg_dict))
File "c:\Program Files\Google\google_appengine\google\appengine\tools\bulkload
er.py", line 4369, in Run
return _PerformBulkload(arg_dict)
File "c:\Program Files\Google\google_appengine\google\appengine\tools\bulkload
er.py", line 4180, in _PerformBulkload
LoadConfig(config_file)
File "c:\Program Files\Google\google_appengine\google\appengine\tools\bulkload
er.py", line 3844, in LoadConfig
('', 'r', imp.PY_SOURCE))
File "card_loader.py", line 3, in <module>
import entities
ImportError: No module named entities
答案 0 :(得分:0)
回溯描述了ImportError
:找不到模块entities
。那是你的模特吗?如果是这样,您必须确保找到它(如果需要,将其目录添加到sys.path
)。