How to use the invenio.sqlalchemyutils.db.Column function in invenio

To help you get started, we’ve selected a few invenio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inveniosoftware / invenio / modules / bibsort / lib / bibsort_model.py View on Github external
primary_key=True, nullable=False)
    name = db.Column(db.String(20), nullable=False, unique=True)
    definition = db.Column(db.String(255), nullable=False)
    washer = db.Column(db.String(255), nullable=False)


class BsrMETHODDATA(db.Model):
    """Represents a BsrMETHODDATA record."""
    __tablename__ = 'bsrMETHODDATA'

    id_bsrMETHOD = db.Column(db.MediumInteger(9, unsigned=True),
                    db.ForeignKey(BsrMETHOD.id),
                    primary_key=True, nullable=False,
                    autoincrement=False)
    data_dict = db.Column(db.LargeBinary)
    data_dict_ordered = db.Column(db.LargeBinary)
    data_list_sorted = db.Column(db.LargeBinary)
    last_updated = db.Column(db.DateTime)


class BsrMETHODDATABUCKET(db.Model):
    """Represents a BsrMETHODDATABUCKET record."""
    __tablename__ = 'bsrMETHODDATABUCKET'

    id_bsrMETHOD = db.Column(db.MediumInteger(9, unsigned=True),
                    db.ForeignKey(BsrMETHOD.id), autoincrement=False,
                    primary_key=True, nullable=False)
    bucket_no = db.Column(db.TinyInteger(2), primary_key=True, nullable=False,
                    autoincrement=False)
    bucket_data = db.Column(db.LargeBinary)
    bucket_last_value = db.Column(db.String(255))
    last_updated = db.Column(db.DateTime)
github inveniosoftware / invenio / modules / weblinkback / lib / weblinkback_model.py View on Github external
class LnkENTRYLOG(db.Model):
    """Represents a LnkENTRYLOG record."""
    __tablename__ = 'lnkENTRYLOG'

    id_lnkENTRY = db.Column(db.Integer(15, unsigned=True),
                db.ForeignKey(LnkENTRY.id), nullable=False, primary_key=True)
    id_lnkLOG = db.Column(db.Integer(15, unsigned=True),
                db.ForeignKey(LnkLOG.id), nullable=False, primary_key=True)


class LnkADMINURLLOG(db.Model):
    """Represents a LnkADMINURLLOG record."""
    __tablename__ = 'lnkADMINURLLOG'

    id_lnkADMINURL = db.Column(db.Integer(15, unsigned=True),
                db.ForeignKey(LnkADMINURL.id), primary_key=True, nullable=False)
    id_lnkLOG = db.Column(db.Integer(15, unsigned=True),
                db.ForeignKey(LnkLOG.id), primary_key=True, nullable=False)


__all__ = [ 'LnkADMINURL',
            'LnkADMINURLLOG',
            'LnkENTRY',
            'LnkENTRYLOG',
            'LnkENTRYURLTITLE',
            'LnkLOG']
github inveniosoftware / invenio / modules / websubmit / lib / websubmit_model.py View on Github external
__tablename__ = 'sbmSUBMISSIONS'
    email = db.Column(db.String(50), nullable=False,
                server_default='')
    doctype = db.Column(db.String(10), nullable=False,
                server_default='')
    action = db.Column(db.String(10), nullable=False,
                server_default='')
    status = db.Column(db.String(10), nullable=False,
                server_default='')
    id = db.Column(db.String(30), nullable=False,
                server_default='')
    reference = db.Column(db.String(40), nullable=False,
                server_default='')
    cd = db.Column(db.DateTime, nullable=False,
                server_default='1900-01-01 00:00:00')
    md = db.Column(db.DateTime, nullable=False,
                server_default='1900-01-01 00:00:00')
    log_id = db.Column(db.Integer(11), nullable=False,
                primary_key=True,
                autoincrement=True)


__all__ = ['SbmACTION',
           'SbmALLFUNCDESCR',
           'SbmAPPROVAL',
           'SbmCATEGORIES',
           'SbmCHECKS',
           'SbmCOLLECTION',
           'SbmCOLLECTIONSbmCOLLECTION',
           'SbmDOCTYPE',
           'SbmCOLLECTIONSbmDOCTYPE',
           'SbmCOOKIES',
github zenodo / zenodo / zenodo / legacy / pidstore_model.py View on Github external
db.Index('idx_action', 'action'),
    )

    id = db.Column(db.Integer(15, unsigned=True), primary_key=True)
    """ Id of persistent identifier entry """

    id_pid = db.Column(
        db.Integer(15, unsigned=True), db.ForeignKey(PersistentIdentifier.id),
        nullable=True,
    )
    """ PID """

    timestamp = db.Column(db.DateTime(), nullable=False, default=datetime.now)
    """ Creation datetime of entry """

    action = db.Column(db.String(10), nullable=False)
    """ Action identifier """

    message = db.Column(db.Text(), nullable=False)
    """ Log message """
github inveniosoftware / invenio / modules / bibworkflow / lib / bibworkflow_model.py View on Github external
"""
    This class represent a record of a log emit by an object
    into the database the object must be saved before using
    this class. Indeed it needs the id of the object into
    the database.
    """
    #db table definition
    __tablename__ = 'bwlOBJECTLOGGING'
    id = db.Column(db.Integer, primary_key=True)
    id_bibworkflowobject = db.Column(db.Integer(255),
                                     db.ForeignKey('bwlOBJECT.id'),
                                     nullable=False)
    log_type = db.Column(db.Integer, default=0, nullable=False)
    created = db.Column(db.DateTime, default=datetime.now)
    message = db.Column(db.TEXT, default="", nullable=False)
    error_msg = db.Column(db.TEXT, default="", nullable=False)
    extra_data = db.Column(db.JSON, default={})

    ###
    #This function should be use only for debug purpose
    #Normal log acces should be done throught the database
    #That's all
    ###
    def __repr__(self):
        return "" % \
               (self.id, self.id_bibworkflowobject, self.message, self.created)

    @classmethod
    def get(cls, *criteria, **filters):
        """ A wrapper for the filter and filter_by functions of sqlalchemy.
        Define a dict with which columns should be filtered by which values.
github inveniosoftware / invenio / modules / websubmit / lib / websubmit_model.py View on Github external
class SbmALLFUNCDESCR(db.Model):
    """Represents a SbmALLFUNCDESCR record."""
    __tablename__ = 'sbmALLFUNCDESCR'
    #FIX ME pk
    function = db.Column(db.String(40), nullable=False, server_default='',
                primary_key=True)
    description	= db.Column(db.TinyText, nullable=True)

class SbmAPPROVAL(db.Model):
    """Represents a SbmAPPROVAL record."""
    __tablename__ = 'sbmAPPROVAL'
    doctype = db.Column(db.String(10), nullable=False,
                server_default='')
    categ = db.Column(db.String(50), nullable=False,
                server_default='')
    rn = db.Column(db.String(50), nullable=False, server_default='',
                primary_key=True)
    status = db.Column(db.String(10), nullable=False,
                server_default='')
    dFirstReq = db.Column(db.DateTime, nullable=False,
        server_default='1900-01-01 00:00:00')
    dLastReq = db.Column(db.DateTime, nullable=False,
        server_default='1900-01-01 00:00:00')
    dAction = db.Column(db.DateTime, nullable=False,
        server_default='1900-01-01 00:00:00')
    access = db.Column(db.String(20), nullable=False,
                server_default='0')
    note = db.Column(db.Text, nullable=False)

class SbmCATEGORIES(db.Model):
    """Represents a SbmCATEGORIES record."""
    __tablename__ = 'sbmCATEGORIES'
github inveniosoftware / invenio / modules / bibrank / lib / bibrank_model.py View on Github external
autoincrement=True)
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                db.ForeignKey(Bibrec.id), nullable=True, primary_key=True)
    id_user = db.Column(db.Integer(15, unsigned=True), db.ForeignKey(User.id),
                server_default='0', primary_key=True)
    client_host = db.Column(db.Integer(10, unsigned=True), nullable=True)
    view_time = db.Column(db.DateTime, primary_key=True,
                server_default='1900-01-01 00:00:00')
    bibrec = db.relationship(Bibrec, backref='pageviews')
    user = db.relationship(User, backref='pageviews')


class RnkWORD01F(db.Model):
    """Represents a RnkWORD01F record."""
    __tablename__ = 'rnkWORD01F'
    id = db.Column(db.MediumInteger(9, unsigned=True), nullable=False,
                primary_key=True, autoincrement=True)
    term = db.Column(db.String(50), nullable=True, unique=True)
    hitlist = db.Column(db.iLargeBinary, nullable=True)


class RnkWORD01R(db.Model):
    """Represents a RnkWORD01R record."""
    __tablename__ = 'rnkWORD01R'
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                db.ForeignKey(Bibrec.id), nullable=False, primary_key=True)
    termlist = db.Column(db.LargeBinary, nullable=True)
    type = db.Column(db.Enum('CURRENT', 'FUTURE', 'TEMPORARY'),
                nullable=False, server_default='CURRENT', primary_key=True)
    bibrec = db.relationship(Bibrec, backref='word01rs')
github inveniosoftware / invenio / modules / webalert / lib / webalert_model.py View on Github external
from invenio.sqlalchemyutils import db

# Create your models here.

from invenio.websession_model import User
from invenio.webbasket_model import BskBASKET
from invenio.websearch_model import WebQuery


class UserQueryBasket(db.Model):
    """Represents a UserQueryBasket record."""
    __tablename__ = 'user_query_basket'
    id_user = db.Column(db.Integer(15, unsigned=True),
                db.ForeignKey(User.id), nullable=False,
                server_default='0', primary_key=True)
    id_query = db.Column(db.Integer(15, unsigned=True),
                db.ForeignKey(WebQuery.id), nullable=False,
                server_default='0', primary_key=True,
                index=True)
    id_basket = db.Column(db.Integer(15, unsigned=True), db.ForeignKey(BskBASKET.id),
                nullable=False,
            server_default='0', primary_key=True,
                index=True)
    frequency = db.Column(db.String(5), nullable=False, server_default='',
                primary_key=True)
    date_creation = db.Column(db.Date, nullable=True)
    date_lastrun = db.Column(db.Date, nullable=True,
                server_default='1900-01-01')
    alert_name = db.Column(db.String(30), nullable=False,
                server_default='', index=True)
    alert_desc = db.Column(db.Text)
    alert_recipient = db.Column(db.Text)
github inveniosoftware / invenio / modules / websearch / lib / websearch_model.py View on Github external
class CollectionFieldFieldvalue(db.Model):
    """Represents a CollectionFieldFieldvalue record."""
    __tablename__ = 'collection_field_fieldvalue'
    id_collection = db.Column(db.MediumInteger(9, unsigned=True),
                db.ForeignKey(Collection.id), primary_key=True, nullable=False)
    id_field = db.Column(db.MediumInteger(9, unsigned=True),
                db.ForeignKey(Field.id), primary_key=True, nullable=False)
    id_fieldvalue = db.Column(db.MediumInteger(9, unsigned=True),
                db.ForeignKey(Fieldvalue.id), primary_key=True, nullable=True)
    type = db.Column(db.Char(3), nullable=False,
                server_default='src')
    score = db.Column(db.TinyInteger(4, unsigned=True), nullable=False,
                server_default='0')
    score_fieldvalue = db.Column(db.TinyInteger(4, unsigned=True),
                nullable=False, server_default='0')

    collection = db.relationship(Collection, backref='field_fieldvalues',
                order_by=score)
    field = db.relationship(Field, backref='collection_fieldvalues',
                lazy='joined')
    fieldvalue = db.relationship(Fieldvalue, backref='collection_fields',
                lazy='joined')


__all__ = ['Collection',
           'Collectionname',
           'Collectiondetailedrecordpagetabs',
           'CollectionCollection',
           'Example',
           'CollectionExample',
github inveniosoftware / invenio / modules / weblinkback / lib / weblinkback_model.py View on Github external
class LnkADMINURL(db.Model):
    """Represents a LnkADMINURL record."""
    __tablename__ = 'lnkADMINURL'

    id = db.Column(db.Integer(15, unsigned=True), primary_key=True,
                nullable=False)
    url = db.Column(db.String(100), nullable=False, unique=True)
    list = db.Column(db.String(30), nullable=False, index=True)


class LnkENTRY(db.Model):
    """Represents a LnkENTRY record."""
    __tablename__ = 'lnkENTRY'

    id = db.Column(db.Integer(15, unsigned=True), primary_key=True, nullable=False)
    origin_url = db.Column(db.String(100), nullable=False)
    id_bibrec = db.Column(db.MediumInteger(8, unsigned=True),
                db.ForeignKey(Bibrec.id), nullable=False)
    additional_properties = db.Column(db.Binary)
    type = db.Column(db.String(30), nullable=False, index=True)
    status = db.Column(db.String(30), nullable=False, server_default='PENDING',
                index=True)
    insert_time = db.Column(db.DateTime, server_default='1900-01-01 00:00:00',
                index=True)

    @property
    def title(self):
        try:
            return db.object_session(self).query(LnkENTRYURLTITLE).\
                filter(db.and_(
                    LnkENTRYURLTITLE.url==self.origin_url,
                    LnkENTRYURLTITLE.title<>"",