region.py 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from sqlalchemy import Integer, Column, String, Float, UniqueConstraint, Index
  4. from db import BaseORMModel
  5. class Region(BaseORMModel):
  6. __tablename__ = "regions"
  7. id = Column(Integer, primary_key=True, autoincrement=True, comment="ID")
  8. code = Column(String(20), nullable=False, comment="区域编码")
  9. name = Column(String(40), nullable=False, comment="区域名称")
  10. pcode = Column(String(20), default="100000", comment="上级区域编码")
  11. shortname = Column(String(40), default="", comment="区域简称")
  12. level = Column(Integer,
  13. nullable=False,
  14. comment="地区级别,1:省/直辖市/自治区,2:地级市/地区/自治州/盟,3:市辖区/县级市/县,4:乡/镇,5:村")
  15. citycode = Column(String(20), default="", comment="区号")
  16. zipcode = Column(String(20), default="", comment="邮政编码")
  17. mergename = Column(String(100), default="", comment="组合名称")
  18. lng = Column(Float, default=0, comment="经度")
  19. lat = Column(Float, default=0, comment="纬度")
  20. pyname = Column(String(100), default="", comment="拼音名称")
  21. __table_args__ = (
  22. UniqueConstraint("code", name="uix_region_code"),
  23. Index("idx_region_name", "name"),
  24. )