class Tag(sqlobject.SQLObject): class sqlmeta(myMeta): pass filedata = sqlobject.ForeignKey('Filedata', cascade=True) tagname = sqlobject.StringCol() tagvalue = sqlobject.StringCol()
class comment(so.SQLObject): post = so.ForeignKey('post', notNone=1) ctime = so.DateTimeCol(notNone=1,default=so.DateTimeCol.now) name = so.StringCol(length=128, notNone=1,default='') email = so.StringCol(length=128, notNone=1,default='') title = so.StringCol(length=128, notNone=1,default='') body = so.StringCol(notNone=1,default='')
class BroadcastTime(sqlobject.SQLObject): """Class voor het databaseobject broadcast_time""" _connection = conn imdb_id = sqlobject.StringCol() ft_starttime = sqlobject.StringCol() ft_endtime = sqlobject.StringCol() ft_channel = sqlobject.StringCol()
class Job(sqlobject.SQLObject): job_id = sqlobject.StringCol() vault_name = sqlobject.StringCol(length=20, default=None) action = sqlobject.StringCol(length=20, default="") creation_date = sqlobject.DateCol(default=None) has_completed = sqlobject.BoolCol(default=False) completion_date = sqlobject.DateCol(default=None) status_code = sqlobject.StringCol(length=10, default="") response_text = sqlobject.StringCol()
class SingleImageRow(sqlobject.SQLObject): # single big text field for tags tags = sqlobject.StringCol() rawData = sqlobject.StringCol() hits = sqlobject.IntCol() originalPathName = sqlobject.StringCol() name = sqlobject.StringCol() dataType = sqlobject.StringCol() series = sqlobject.ForeignKey("ImageSeriesRow", default=None)
class Package(sqlobject.SQLObject): """Class implemeting a Debian package""" name = sqlobject.StringCol() version = sqlobject.StringCol(default=None) priority = sqlobject.StringCol(default=None) @staticmethod def version_compare(a, b): return apt_pkg.version_compare(a.version, b.version)
class License(sqlobject.SQLObject): class sqlmeta(myMeta): pass license = sqlobject.StringCol(alternateID=True) license_type = sqlobject.StringCol() filesWith = sqlobject.RelatedJoin('License', otherColumn='filedata_id', joinColumn='license_id', intermediateTable='filedata_license', addRemoveName='FileWith')
class PythonScore(sqlobject.SQLObject): """ OO mapping of the score for a Python file """ username = sqlobject.StringCol() pathname = sqlobject.StringCol() revision = sqlobject.StringCol() score = sqlobject.FloatCol() old_score = sqlobject.FloatCol() credit = sqlobject.FloatCol() date = sqlobject.DateTimeCol(default=sqlobject.DateTimeCol.now)
class User(sqlobject.SQLObject): _connection = establish_connection() userName = sqlobject.StringCol(length=100, unique=False) age = sqlobject.IntCol(default=None) height = sqlobject.IntCol(default=None) weight = sqlobject.IntCol(default=None) gender = sqlobject.StringCol(length=6) activity = sqlobject.FloatCol(default=None) def __repr__(self): return "name: {}\nage: {}\nheight: {}\nweight: {}\ngender: {}\nactv: {}".format(self.userName,\ self.age, self.height, self.weight, self.gender, self.activity)
class URL(sqlobject.SQLObject): class sqlmeta: table = 'url' url = sqlobject.StringCol() clean = sqlobject.StringCol() author = sqlobject.ForeignKey('Author') channel = sqlobject.ForeignKey('Channel') citations = sqlobject.IntCol(default=0) posted = sqlobject.DateTimeCol(default=datetime.now) comments = sqlobject.MultipleJoin('Comments')
class Job(sqlobject.SQLObject): status = sqlobject.IntCol(default=JobStatus.UNKNOWN) package = sqlobject.ForeignKey('Package', cascade=True) dist = sqlobject.StringCol(default='unreleased') arch = sqlobject.StringCol(default='any') creation_date = sqlobject.DateTimeCol(default=sqlobject.DateTimeCol.now) build_host = sqlobject.StringCol(default=None) status_changed = sqlobject.DateTimeCol(default=None) build_start = sqlobject.DateTimeCol(default=None) build_end = sqlobject.DateTimeCol(default=None) def __init__(self, *args, **kwargs): sqlobject.SQLObject.__init__(self, *args, **kwargs) self.status_lock = status_lock def __setattr__(self, name, value): if name == "status": self.status_changed = sqlobject.DateTimeCol.now() sqlobject.SQLObject.__setattr__(self, name, value) def dict(self): result = { "id": self.id, "task": "%s/%s" % (self.dist, self.arch), "build_host": self.build_host, "status": JobStatus.whatis(self.status), "dist": self.dist, "arch": self.arch, "creation_date": try_strftime(self.creation_date), "build_start": try_strftime(self.build_start), "build_end": try_strftime(self.build_end), "status_changed": try_strftime(self.status_changed) } return result def start(self, slave, builder): if self.status != JobStatus.WAIT_LOCKED: raise ValueError("JobStatus is not WAIT_LOCKED") else: self.status = JobStatus.BUILDING self.build_start = sqlobject.DateTimeCol.now() self.build_host = slave.name kwargs = self.dict() kwargs.update(self.package.dict()) return slave.build(self.id, builder, kwargs)
class ZeropointEntry(sqlobject.inheritance.InheritableSQLObject): user = sqlobject.StringCol() time = sqlobject.DateTimeCol() cluster = sqlobject.StringCol() filter = sqlobject.StringCol() zp = sqlobject.FloatCol() mangledSpecification = sqlobject.StringCol() def _get_specification(self): return unmangleSpecification(self.mangledSpecification) def _set_specification(self, **specification): self.mangledSpecification = mangleSpecification(specification)
class Campaign(so.SQLObject): """ Model a Campaign, which can be assigned to a Tweet as a label. Used to group Tweets which are added to the DB because they matched the same campaign, such as a search topic. See docs/models.md document. """ class sqlmeta: defaultOrder = "name" # Campaign name can be any case and may have spaces. name = so.StringCol(alternateID=True, length=50) # Query string to use on Twitter API search, whether manually or on # schedule. This is optional, to allow campaigns which are not searches. searchQuery = so.StringCol(default=None) createdAt = so.DateTimeCol(notNull=True, default=so.DateTimeCol.now) # Link to Tweet objects assigned to the Campaign. tweets = so.SQLRelatedJoin("Tweet", intermediateTable="tweet_campaign", createRelatedTable=False) @classmethod def getOrCreate(cls, campaignName, query=None): """ Get a campaign otherwise create and return one. Query may be empty as in some cases like a utility's campaign label the campaign is a label for grouping rather than searching. """ try: return cls.byName(campaignName) except SQLObjectNotFound: return cls(name=campaignName, searchQuery=query) @classmethod def getOrRaise(cls, campaignName): """ Get campaign by name otherwise raise an error, with instructions. """ try: return cls.byName(campaignName) except SQLObjectNotFound as e: raise type(e)( "Use the campaign manager to create the Campaign" " as name and search query. Name not found: {!r}".format( campaignName))
class Message(orm.SQLObject): """The class generates a Message table containing information about user messages. Args: text (str, optional): time (int, optional): filePicture (byte, optional): fileVideo (byte, optional): fileAudio (byte, optional): fileDocument (byte, optional): emoji (str, optional): editedTime (int, optional): editedStatus (bool, optional): Returns: None """ text = orm.StringCol(default=None) time = orm.IntCol(default=None) filePicture = orm.BLOBCol(default=None) fileVideo = orm.BLOBCol(default=None) fileAudio = orm.BLOBCol(default=None) fileDocument = orm.BLOBCol(default=None) emoji = orm.BLOBCol(default=None) editedTime = orm.IntCol(default=None) editedStatus = orm.BoolCol(default=False) userConfig = orm.ForeignKey('UserConfig', refColumn="uuid") flow = orm.ForeignKey('Flow', refColumn="flowId")
class Medicion(SO.SQLObject, Serializer): class sqlmeta: style = SO.MixedCaseStyle(longID=True) nombre = SO.StringCol(length=40, varchar=True) intervalo = SO.IntCol() linea = SO.ForeignKey('Linea') unidad = SO.ForeignKey('Unidad')
class Errors(orm.SQLObject): """The class generates an Errors table in which all types of errors are pre-stored. Args: status (str, optional): code (int, optional): detail (str, optional): Returns: None """ # status and code is standart HTTP status code status = orm.StringCol(default=None) code = orm.IntCol(default=None) detail = orm.StringCol(default=None)
class ObservationCalibration(sqlobject.SQLObject): cluster = sqlobject.StringCol(length=55) filter = sqlobject.StringCol(length=55) mangledSpecification = sqlobject.StringCol(length=250) calibration = sqlobject.ForeignKey('ZeropointEntry') ClusterFilterIndex = sqlobject.DatabaseIndex('cluster', 'filter', 'mangledSpecification', unique=True) def _get_specification(self): return unmangleSpecification(self.mangledSpecification) def _set_specification(self, **specification): self.mangledSpecification = mangleSpecification(specification)
class Author(sqlobject.SQLObject): name = sqlobject.StringCol(alternateID=True, length=50) urls = sqlobject.MultipleJoin('URL') comments = sqlobject.MultipleJoin('Comments') points_new = sqlobject.IntCol(default=0) points_old = sqlobject.IntCol(default=0) points_credit = sqlobject.IntCol(default=0)
class Product(sqlobject.SQLObject): _connection = establish_connection() productName = sqlobject.StringCol(length=100) energyPoints = sqlobject.IntCol(default=None) date = sqlobject.DateCol() def __repr__(self): return "date: {} name = {}, energy = {}".format(self.date,\ self.productName, self.energyPoints)
class Guest(DictSQLObject): """ Collects information about Guests Refrenced to by the ChatMsg Table """ name = so.UnicodeCol() admin = so.BoolCol(default=False) parprop = so.IntCol(default=-1) token = so.StringCol(length=8) event = so.ForeignKey('Event')
class P2spTask(sqlobject.SQLObject): # app_id = sqlobject.StringCol(length=14, unique=True) TaskId = sqlobject.BigIntCol(length=0, dbName='TaskId', alternateID=False) ResourceUsageStrategy = sqlobject.IntCol( length=0, dbName='ResourceUsageStrategy') ResourceReportStrategy = sqlobject.IntCol( length=0, dbName='ResourceReportStrategy') Cookie = sqlobject.StringCol(length=0) AccountNeeded = sqlobject.IntCol(length=0, dbName='AccountNeeded') UserName = sqlobject.StringCol(length=0, dbName='UserName') Password = sqlobject.StringCol(length=0) UseOriginResourceOnly = sqlobject.IntCol( length=0, dbName='UseOriginResourceOnly') OriginResourceSupportRange = sqlobject.IntCol( length=0, dbName='OriginResourceSupportRange') ReceiveOriginResourceSize = sqlobject.BigIntCol( length=0, dbName='ReceiveOriginResourceSize') OriginResourceRetryInterval = sqlobject.IntCol( length=0, dbName='OriginResourceRetryInterval') OriginResourceRetryTimes = sqlobject.IntCol( length=0, dbName='OriginResourceRetryTimes') OriginResourceThreadCount = sqlobject.IntCol( length=0, dbName='OriginResourceThreadCount') DownloadSpeedLimit = sqlobject.IntCol(length=0, dbName='DownloadSpeedLimit') FileNameFixed = sqlobject.IntCol(length=0, dbName='FileNameFixed') HttpRequestHeader = sqlobject.BLOBCol(length=0, dbName='HttpRequestHeader') VideoHeadFirstTime = sqlobject.IntCol(length=0, dbName='VideoHeadFirstTime') VideoHeadFirstStatus = sqlobject.IntCol(length=0, dbName='VideoHeadFirstStatus') ResourceQuerySize = sqlobject.BigIntCol(length=0, dbName='ResourceQuerySize') DisplayUrl = sqlobject.StringCol(length=0, dbName='DisplayUrl') UserAgent = sqlobject.StringCol(length=0, dbName='UserAgent') class sqlmeta: table = 'P2spTask' idName = 'TaskId'
class AddressbookContact_sqlite(sqlobject.SQLObject): class sqlmeta: table = "contacts" name = sqlobject.StringCol() phone = sqlobject.StringCol() email = sqlobject.StringCol() copia_agenda_id = sqlobject.StringCol() modification_stringdate = sqlobject.StringCol() def save(self): _addressbook_manager = AddressbookManager() _addressbook_manager.update_model() def destroySelf(self, notify=True): sqlobject.SQLObject.destroySelf(self) if notify: _addressbook_manager = AddressbookManager() _addressbook_manager.update_model()
class Flow(orm.SQLObject): """The class generates a Flow table containing information about threads and their types (chat, channel, group). Args: flowId (int, required): timeCreated (int, optional): flowType (str, optional): title (str, optional): info (str, optional): Returns: None """ flowId = orm.IntCol(alternateID=True, unique=True, notNone=True) timeCreated = orm.IntCol(default=None) flowType = orm.StringCol(default=None) title = orm.StringCol(default=None) info = orm.StringCol(default=None) # Connection to the Message table message = orm.MultipleJoin('Message')
class Log(sqlobject.SQLObject): timestamp = sqlobject.DateTimeCol(default=sqlobject.DateTimeCol.now()) status = sqlobject.BoolCol(default=True) section = sqlobject.StringCol() message = sqlobject.StringCol() def __init__(self, *args, **kwargs): sqlobject.SQLObject.__init__(self, *args, **kwargs) def __setattr__(self, name, value): sqlobject.SQLObject.__setattr__(self, name, value) def dict(self): result = { "id": self.id, "timestamp": try_strftime(self.timestamp, default='never'), "section": self.section, "status": self.status, "message": self.message } return result
class FileMeta(sqlobject.SQLObject, File): """ store rating metadata about a file, create thumbnails, and more! """ class sqlmeta: lazyUpdate = True # must call #syncUpdate or #sync to save changes MOCK = False absolute = sqlobject.StringCol(notNone=True, unique=True, alternateID=True) hits = sqlobject.IntCol(notNone=True, default=0) rating = sqlobject.FloatCol(notNone=True, default=0.0) rating_hits = sqlobject.IntCol(notNone=True, default=0) def rate(self, rating): """ store an incoming rating value, out of 10 would rate/10 """ # no crazy bznz if rating > 10 or rating < 0: raise ValueError('Rating value out of bounds [0 - 10]') return self.rating so_far = self.rating * self.ratingHits now = (so_far + rating) / (self.rating_hits + 1) self.rating = now self.ratingHits = self.rating_hits + 1 self.syncUpdate() return now def hit(self): self.hits += 1 self.syncUpdate() return self.hits @classmethod def for_path(cls, absolute, root=None): """get or create for this path""" if cls.MOCK: return MockFileMeta(absolute=absolute, hits=0, rating=5.5, rating_hits=100) try: instance = cls.byAbsolute(absolute) except sqlobject.SQLObjectNotFound: instance = cls(absolute=absolute) instance.syncUpdate() instance.root = root return instance
class Filedata(sqlobject.SQLObject): class sqlmeta(myMeta): pass basename = sqlobject.StringCol() full_path = sqlobject.StringCol(alternateID=True) dt_needed = sqlobject.RelatedJoin('Soname', joinColumn='filedata_id', otherColumn='soname_id', intermediateTable='dt_needed_list', addRemoveName='DtNeeded') soname = sqlobject.RelatedJoin('Soname', joinColumn='filedata_id', otherColumn='soname_id', intermediateTable='soname_list', addRemoveName='Soname') license = sqlobject.RelatedJoin('License', joinColumn='filedata_id', otherColumn='license_id', intermediateTable='filedata_license', addRemoveName='License') tags = sqlobject.MultipleJoin('Tag')
class Soname(sqlobject.SQLObject): class sqlmeta(myMeta): pass soname = sqlobject.StringCol(alternateID=True) needed_by = sqlobject.RelatedJoin('Filedata', otherColumn='filedata_id', joinColumn='soname_id', intermediateTable='dt_needed_list', addRemoveName='FileThatRequires') has_soname = sqlobject.RelatedJoin('Filedata', otherColumn='filedata_id', joinColumn='soname_id', intermediateTable='soname_list', addRemoveName='FileWithSoname')
class Country(Place): """ Place which is a Country in Twitter API. """ _inheritable = False # Continent which this Country belongs to. continent = so.ForeignKey("Continent", default=None) # Get Town objects belonging to the Country. Defaults to null list. hasTowns = so.MultipleJoin("Town") # Two-character string as the country's code. countryCode = so.StringCol(length=2, default=None)
class Category(so.SQLObject): """ Model a Category, which can be assigned to Profiles. Group similar profiles in a category. See docs/models.md document. """ class sqlmeta: defaultOrder = "name" # Category name can be any case and may have spaces. name = so.StringCol(alternateID=True, length=50) createdAt = so.DateTimeCol(notNull=True, default=so.DateTimeCol.now) # Get Profile objects assigned to the Category. profiles = so.SQLRelatedJoin("Profile", intermediateTable="profile_category", createRelatedTable=False)
class UserConfig(orm.SQLObject): """The class generates a table containing data about the user and his settings. Args: uuid (int, required): login (str, required): password (str, required): hash_password (str, optional) username (str, optional): isBot (bool, optional): default False authId (str, optional): email (str, optional): avatar (str, optional): bio (str, optional): salt (str, optional): key (str, optional): Returns: None """ # added alternateID for added class method @byUUID # which will return that object uuid = orm.IntCol(alternateID=True, unique=True, notNone=True) login = orm.StringCol() password = orm.StringCol() hashPassword = orm.StringCol(default=None) username = orm.StringCol(default=None) isBot = orm.BoolCol(default=False) authId = orm.StringCol(default=None) email = orm.StringCol(default=None) avatar = orm.BLOBCol(default=None) bio = orm.StringCol(default=None) salt = orm.BLOBCol(default=None) key = orm.BLOBCol(default=None) # Connection to the Message table message = orm.MultipleJoin('Message')