search

Home  >  Q&A  >  body text

关于python中生成唯一ID

python 中除了UUID可以生成唯一ID外,还有其他方法吗?这个UUID虽然可以做到,但太长了,有没有生成唯一ID比较短的方法?

PHP中文网PHP中文网2804 days ago1165

reply all(4)I'll reply

  • 迷茫

    迷茫2017-04-17 18:03:30

    Wouldn’t it be enough to automatically increase the player character ID and database ID?
    You don’t need to set the ID yourself
    Every time you add a new role, the server ID will be automatically +1
    It will be unique in the same table

    If it is multiple tables

    Unique ID solution for sub-database and sub-table,
    You can create a special ID table id_table, with only one column of ID and it is the primary key
    Every time you insert a player role player_role record, first insert a record into the id_table and then
    use LAST_INSERT_ID as player_role new id

    reply
    0
  • 黄舟

    黄舟2017-04-17 18:03:30

    How can it be guaranteed to be unique if it’s too short?

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 18:03:30

    Maybe you can refer to it first:

    shortuuid


    Questions I answered: Python-QA

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 18:03:30

    A self-increasing int64 or something is fine

    reply
    0
  • Cancelreply