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
aoscici2000
V2EX  ›  Python

peewee PrimaryKeyField 如何设置自增开始值

  •  
  •   aoscici2000 · 2019-07-30 01:08:11 +08:00 · 2008 次点击
    这是一个创建于 1725 天前的主题,其中的信息可能已经有所发展或是发生改变。
    
    class Article(BaseModel):
        id = PrimaryKeyField()
        author = CharField()
        content = TextField()
    
        class Meta:
            db_table = 'article'
            
    

    如题, 想让 id 从 10000 开始自增, 请问下在哪设置?

    1 条回复    2019-07-30 09:08:13 +08:00
    mywaiting
        1
    mywaiting  
       2019-07-30 09:08:13 +08:00   ❤️ 1
    peewee 好像不支持这个自增起始值的设置?我翻过它的源代码,好像没有地方可以设置的

    可以在建库后,自己在数据库里面执行 SQL 语句指定自增起始值
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5440 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 03:34 · PVG 11:34 · LAX 20:34 · JFK 23:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.