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
1ane
V2EX  ›  Python

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

  •  
  •   1ane · 2014-11-25 09:19:40 +08:00 · 1646 次点击
    这是一个创建于 3438 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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
       2014-11-25 19:31:22 +08:00
    终于懂了,应该是where="username='Mark'"

    Σ( ° △ °|||)︴
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4481 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:10 · PVG 18:10 · LAX 03:10 · JFK 06:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.