V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
loading
V2EX  ›  Python

wsgi部署后的路径问题

  •  
  •   loading ·
    ycf · 2011-11-11 19:27:21 +08:00 · 4247 次点击
    这是一个创建于 4543 天前的主题,其中的信息可能已经有所发展或是发生改变。
    使用Flask写了个小程序,使用的是sqlite3,用的flask例子的部分代码:
    DATABASE = 'sqlite.db'

    def connect_db():
    """Returns a new connection to the database."""
    return sqlite3.connect(app.config['DATABASE'])

    在部署wsgi后,浏览器出500,error.log:
    [Fri Nov 11 19:18:09 2011] [error] [client 127.0.0.1] OperationalError: no such table: user, referer: http://127.0.0.1:8080/login

    应该是路径问题吧,请问如何解决呢?
    4 条回复    1970-01-01 08:00:00 +08:00
    Livid
        1
    Livid  
    MOD
       2011-11-11 20:20:33 +08:00
    如果确实是数据问题,那么 DATABASE = '/your/absolute/path/to/sqlite.db' 吧。
    lepture
        2
    lepture  
       2011-11-12 01:23:22 +08:00 via iPhone
    对,用绝对路径。
    loading
        3
    loading  
    OP
       2011-11-12 14:47:02 +08:00
    @lepture @Livid 使用绝对路径好了,感谢。能不能别写死路径呢?应该是可以的吧,os.path
    lepture
        4
    lepture  
       2011-11-12 16:29:08 +08:00
    @loading os.path.join(os.path.dirname(__file__), 'yourdb.sqlite')
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   944 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:22 · PVG 06:22 · LAX 15:22 · JFK 18:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.