如何使用Python将数据加载到本地开发服务器?

如何使用Python将数据加载到本地开发服务器?,python,google-app-engine,Python,Google App Engine,我知道GAE帮助网站中详细介绍了这一点。这对我不起作用。我对Python有点生疏。但我也知道进口是如何运作的。实体模块就在加载程序所在的同一文件夹中。那么GAE脚本在做什么 这是我的加载器: from google.appengine.ext import db from google.appengine.tools import bulkloader import entities class CardLoader(bulkloader.Loader): def __init__(s

我知道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\u appengine\appcfg.py 上传数据-config\u file=card\u loader.py-url -文件名=card\u data.csv-种类=卡片

以下是输出:

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

回溯描述了一个错误:未找到模块实体。你的模特就在那里吗?如果是这样,您必须确保可以找到它,并在需要时将其目录添加到sys.path。

它实际上位于本地路径中。appcfg.py在windows上的行为是否有所不同?我将尝试FQ路径。我必须这样做:导入sys import os\u root\u dir=os.path.dirnameos.path.realpath文件sys.path.insert0,\u root\u dir导入实体