推荐学习书目
› 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 · Nov 11, 2011 · 5320 views
    This topic created in 5436 days ago, the information mentioned may be changed or developed.
    使用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 replies  •  1970-01-01 08:00:00 +08:00
    Livid
        1
    Livid  
    MOD
    PRO
       Nov 11, 2011
    如果确实是数据问题,那么 DATABASE = '/your/absolute/path/to/sqlite.db' 吧。
    lepture
        2
    lepture  
       Nov 12, 2011 via iPhone
    对,用绝对路径。
    loading
        3
    loading  
    OP
       Nov 12, 2011
    @lepture @Livid 使用绝对路径好了,感谢。能不能别写死路径呢?应该是可以的吧,os.path
    lepture
        4
    lepture  
       Nov 12, 2011
    @loading os.path.join(os.path.dirname(__file__), 'yourdb.sqlite')
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2916 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 10:25 · PVG 18:25 · LAX 03:25 · JFK 06:25
    ♥ Do have faith in what you're doing.