推荐学习书目
› 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
1ane
V2EX  ›  Python

web.py 使用 db.select 时遇到的问题,求助!

  •  
  •   1ane · Nov 25, 2014 · 2211 views
    This topic created in 4324 days ago, the information mentioned may be changed or developed.
    def get_content(fromUser):
    return db.select('table1', where="id=3")

    ------
    for item in model.get_content(fromUser):
    print item.content

    这样是可以得到正确结果的,但是如果改成

    def get_content(fromUser):
    return db.select('table1', where="username=Mark",offset=1)

    这样就会出问题,我把offset 改成-1,0什么的试过,也不行,去掉offset,写limit=1(因为我只想要一个item)还是不行

    这是不是因为字段不同?

    id字段AUTO_INCREMENT,PRIMARY,INT
    username字段 TEXT

    还是有其他原因? 网上查了一些资料,不是很详细,看不懂。

    求指教
    1ane
        1
    1ane  
    OP
       Nov 25, 2014
    终于懂了,应该是where="username='Mark'"

    Σ( ° △ °|||)︴
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   806 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:59 · PVG 05:59 · LAX 14:59 · JFK 17:59
    ♥ Do have faith in what you're doing.