推荐学习书目
› 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 · Jul 30, 2019 · 2934 views
    This topic created in 2615 days ago, the information mentioned may be changed or developed.
    
    class Article(BaseModel):
        id = PrimaryKeyField()
        author = CharField()
        content = TextField()
    
        class Meta:
            db_table = 'article'
            
    

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

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

    可以在建库后,自己在数据库里面执行 SQL 语句指定自增起始值
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1419 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:41 · PVG 00:41 · LAX 09:41 · JFK 12:41
    ♥ Do have faith in what you're doing.