/weave/server/storage/sqlmappers.py
Python | 63 lines | 41 code | 18 blank | 4 comment | 0 complexity | 713a68c65daba891332fc933cc4d3acc MD5 | raw file
- """ SQL Mappers
- """
- from sqlalchemy.ext.declarative import declarative_base, Column
- from sqlalchemy import Integer, String, DateTime, Text
- _Base = declarative_base()
- tables = []
- class Collections(_Base):
- __tablename__ = 'collections'
- # XXX add indexes
- userid = Column(Integer, primary_key=True, nullable=False)
- collectionid = Column(Integer, primary_key=True, nullable=False)
- name = Column(String, nullable=False)
- collections = Collections.__table__
- tables.append(collections)
- class Users(_Base):
- __tablename__ = 'users'
- id = Column(Integer, primary_key=True, nullable=False)
- username = Column(String(32))
- password_hash = Column(String(128))
- email = Column(String(64))
- status = Column(Integer)
- alert = Column(Text)
- users = Users.__table__
- tables.append(users)
- class ResetCodes(_Base):
- __tablename__ = 'reset_codes'
- username = Column(String, primary_key=True, nullable=False)
- reset = Column(String)
- expiration = Column(DateTime)
- reset_code = ResetCodes.__table__
- tables.append(reset_code)
- class WBO(_Base):
- __tablename__ = 'wbo'
- id = Column(Integer, primary_key=True)
- # XXX that's user id in fact
- username = Column(Integer, primary_key=True)
- collection = Column(Integer, primary_key=True)
- parentid = Column(String)
- predecessorid = Column(String)
- sortindex = Column(Integer)
- modified = Column(Integer)
- payload = Column(Text)
- payload_size = Column(Integer)
- wbo = WBO.__table__
- tables.append(wbo)