PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/weave/server/storage/sqlmappers.py

https://bitbucket.org/tarek/python-weave-server
Python | 63 lines | 41 code | 18 blank | 4 comment | 0 complexity | 713a68c65daba891332fc933cc4d3acc MD5 | raw file
  1. """ SQL Mappers
  2. """
  3. from sqlalchemy.ext.declarative import declarative_base, Column
  4. from sqlalchemy import Integer, String, DateTime, Text
  5. _Base = declarative_base()
  6. tables = []
  7. class Collections(_Base):
  8. __tablename__ = 'collections'
  9. # XXX add indexes
  10. userid = Column(Integer, primary_key=True, nullable=False)
  11. collectionid = Column(Integer, primary_key=True, nullable=False)
  12. name = Column(String, nullable=False)
  13. collections = Collections.__table__
  14. tables.append(collections)
  15. class Users(_Base):
  16. __tablename__ = 'users'
  17. id = Column(Integer, primary_key=True, nullable=False)
  18. username = Column(String(32))
  19. password_hash = Column(String(128))
  20. email = Column(String(64))
  21. status = Column(Integer)
  22. alert = Column(Text)
  23. users = Users.__table__
  24. tables.append(users)
  25. class ResetCodes(_Base):
  26. __tablename__ = 'reset_codes'
  27. username = Column(String, primary_key=True, nullable=False)
  28. reset = Column(String)
  29. expiration = Column(DateTime)
  30. reset_code = ResetCodes.__table__
  31. tables.append(reset_code)
  32. class WBO(_Base):
  33. __tablename__ = 'wbo'
  34. id = Column(Integer, primary_key=True)
  35. # XXX that's user id in fact
  36. username = Column(Integer, primary_key=True)
  37. collection = Column(Integer, primary_key=True)
  38. parentid = Column(String)
  39. predecessorid = Column(String)
  40. sortindex = Column(Integer)
  41. modified = Column(Integer)
  42. payload = Column(Text)
  43. payload_size = Column(Integer)
  44. wbo = WBO.__table__
  45. tables.append(wbo)