How to use the extensions.db.Column function in extensions

To help you get started, we’ve selected a few extensions 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 dlapiduz / govcode.org / models.py View on Github external
name = db.Column(db.String(100))
    username = db.Column(db.String(50), unique=True)
    slug = db.Column(db.String(100), unique=True)
    ignore = db.Column(db.Boolean, default=False)

    def __repr__(self):
        return '' % self.name

class Repository(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    gh_id = db.Column(db.Integer)
    name = db.Column(db.String(100))
    forks = db.Column(db.Integer)
    watchers = db.Column(db.Integer)
    size = db.Column(db.Integer)
    open_issues = db.Column(db.Integer)
    description = db.Column(db.Text)
    organization_id = db.Column(db.Integer, db.ForeignKey('organization.id'))
    organization = db.relationship('Organization',
        backref=db.backref('repositories', lazy='dynamic'))
    users = db.relationship("User", secondary="commit", backref="repositories")
    slug = db.Column(db.String(100), unique=True)
    last_commit_date = db.Column(db.DateTime)

    @hybrid_property
    def last_commit(self):
        return self.commits.order_by(desc(Commit.date)).first()

    def __repr__(self):
        return '' % self.name

class Commit(db.Model):
github openml / openml.org / models.py View on Github external
from extensions import db
from flask_login import UserMixin
from extensions import loginmgr
from extensions import argon2
#from sqlalchemy import db.Column,db. Integer, String, ForeignKey, Date

@loginmgr.user_loader
def load_user(id):
    return User.query.get(int(id))

class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    ip_address = db.Column(db.String(64))
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password = db.Column(db.String(240))
    activation_selector = db.Column(db.String(120))
    activation_code = db.Column(db.String(120))
    forgotten_password_selector = db.Column(db.String(120))
    forgotten_password_code = db.Column(db.String(120))
    forgotten_password_time = db.Column(db.String(120))
    remember_selector = db.Column(db.String(120))
    remember_code = db.Column(db.String(120))
    created_on = db.Column(db.String(120))
    last_login = db.Column(db.String(120))
    active = db.Column(db.String(120))
    first_name = db.Column(db.String(120))
    last_name = db.Column(db.String(120))
github pycook / cmdb / models / ci_type.py View on Github external
# -*- coding:utf-8 -*- 

from extensions import db
from extensions import cache


class CIType(db.Model):
    __tablename__ = "ci_types"

    type_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    type_name = db.Column(db.String(32))
    type_alias = db.Column(db.String(32))
    uniq_id = db.Column(db.Integer,
                        db.ForeignKey("ci_attributes.attr_id"),
                        nullable=False)
    uniq_key = db.relationship("CIAttribute", backref="ci_types")
    enabled = db.Column(db.Boolean, default=True, nullable=False)
    is_attached = db.Column(db.Boolean, default=False, nullable=False)
    icon_url = db.Column(db.String(256))
    order = db.Column(db.SmallInteger, default=0, nullable=False)


class CITypeAttribute(db.Model):
    __tablename__ = "type_attributes"

    type_id = db.Column(db.Integer,
github openml / openml.org / models.py View on Github external
password = db.Column(db.String(240))
    activation_selector = db.Column(db.String(120))
    activation_code = db.Column(db.String(120))
    forgotten_password_selector = db.Column(db.String(120))
    forgotten_password_code = db.Column(db.String(120))
    forgotten_password_time = db.Column(db.String(120))
    remember_selector = db.Column(db.String(120))
    remember_code = db.Column(db.String(120))
    created_on = db.Column(db.String(120))
    last_login = db.Column(db.String(120))
    active = db.Column(db.String(120))
    first_name = db.Column(db.String(120))
    last_name = db.Column(db.String(120))
    company = db.Column(db.String(120))
    phone = db.Column(db.String(120))
    country = db.Column(db.String(120))
    image = db.Column(db.String(120))
    bio = db.Column(db.String(240))
    core = db.Column(db.String(240))
    external_source = db.Column(db.String(120))
    external_id = db.Column(db.String(120))
    session_hash = db.Column(db.String(120))

    def set_password(self, password):
        self.password_hash = argon2.generate_password_hash(password)

    def check_password(self, password):
        password = argon2.generate_password_hash(password)
        return argon2.check_password_hash(self.password_hash, password)
    def __repr__(self):
        return ''.format(self.username)
github dlapiduz / govcode.org / models.py View on Github external
id = db.Column(db.Integer, primary_key=True)
    sha = db.Column(db.String(70))
    message = db.Column(db.Text)
    date = db.Column(db.DateTime)
    repository_id = db.Column(db.Integer, db.ForeignKey('repository.id'))
    repository = db.relationship('Repository',
        backref=db.backref('commits', lazy='dynamic'))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User',
        backref=db.backref('commits', lazy='dynamic'))

    def __repr__(self):
        return '' % self.message

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    gh_id = db.Column(db.Integer)
    login = db.Column(db.String(70))
    avatar_url = db.Column(db.String(255))
    slug = db.Column(db.String(70), unique=True)
    commit_count = db.column_property(
            select([func.count(Commit.id)]).\
            where(Commit.user_id==id).\
            correlate_except(Commit)
    )

    @hybrid_property
    def organizations(self):
        return list(set(repo.organization for repo in self.repositories))

    def __repr__(self):
        return '' % self.login
github dlapiduz / govcode.org / models.py View on Github external
import datetime
from flask import url_for
from extensions import db
from helpers import slugify
import json
from decimal import Decimal
from sqlalchemy import event, desc, func, select
from sqlalchemy.ext.hybrid import hybrid_property

from collections import OrderedDict


class Organization(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    username = db.Column(db.String(50), unique=True)
    slug = db.Column(db.String(100), unique=True)
    ignore = db.Column(db.Boolean, default=False)

    def __repr__(self):
        return '' % self.name

class Repository(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    gh_id = db.Column(db.Integer)
    name = db.Column(db.String(100))
    forks = db.Column(db.Integer)
    watchers = db.Column(db.Integer)
    size = db.Column(db.Integer)
    open_issues = db.Column(db.Integer)
    description = db.Column(db.Text)
    organization_id = db.Column(db.Integer, db.ForeignKey('organization.id'))
github pycook / cmdb / models / history.py View on Github external
attr_id = db.Column(db.Integer, nullable=False)
    old = db.Column(db.Text)
    new = db.Column(db.Text)


class CIRelationHistory(db.Model):
    __tablename__ = "relation_histories"

    rh_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    operate_type = db.Column(db.Enum("add", "delete", name="operate_type"))
    record_id = db.Column(db.Integer,
                          db.ForeignKey("records.record_id"),
                          nullable=False)
    first_ci_id = db.Column(db.Integer)
    second_ci_id = db.Column(db.Integer)
    relation_type = db.Column(
        db.Enum("connect", "deploy", "install", "contain",
                name="relation_type"))
    relation = db.Column(db.Integer, nullable=False)
github openml / openml.org / models.py View on Github external
from extensions import db
from flask_login import UserMixin
from extensions import loginmgr
from extensions import argon2
#from sqlalchemy import db.Column,db. Integer, String, ForeignKey, Date

@loginmgr.user_loader
def load_user(id):
    return User.query.get(int(id))

class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    ip_address = db.Column(db.String(64))
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password = db.Column(db.String(240))
    activation_selector = db.Column(db.String(120))
    activation_code = db.Column(db.String(120))
    forgotten_password_selector = db.Column(db.String(120))
    forgotten_password_code = db.Column(db.String(120))
    forgotten_password_time = db.Column(db.String(120))
    remember_selector = db.Column(db.String(120))
    remember_code = db.Column(db.String(120))
    created_on = db.Column(db.String(120))
    last_login = db.Column(db.String(120))
    active = db.Column(db.String(120))
    first_name = db.Column(db.String(120))
    last_name = db.Column(db.String(120))
    company = db.Column(db.String(120))
github openml / openml.org / models.py View on Github external
ip_address = db.Column(db.String(64))
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password = db.Column(db.String(240))
    activation_selector = db.Column(db.String(120))
    activation_code = db.Column(db.String(120))
    forgotten_password_selector = db.Column(db.String(120))
    forgotten_password_code = db.Column(db.String(120))
    forgotten_password_time = db.Column(db.String(120))
    remember_selector = db.Column(db.String(120))
    remember_code = db.Column(db.String(120))
    created_on = db.Column(db.String(120))
    last_login = db.Column(db.String(120))
    active = db.Column(db.String(120))
    first_name = db.Column(db.String(120))
    last_name = db.Column(db.String(120))
    company = db.Column(db.String(120))
    phone = db.Column(db.String(120))
    country = db.Column(db.String(120))
    image = db.Column(db.String(120))
    bio = db.Column(db.String(240))
    core = db.Column(db.String(240))
    external_source = db.Column(db.String(120))
    external_id = db.Column(db.String(120))
    session_hash = db.Column(db.String(120))

    def set_password(self, password):
        self.password_hash = argon2.generate_password_hash(password)

    def check_password(self, password):
        password = argon2.generate_password_hash(password)
        return argon2.check_password_hash(self.password_hash, password)
github pycook / cmdb / models / attribute.py View on Github external
# -*- coding:utf-8 -*- 

from extensions import db, cache


class CIAttribute(db.Model):
    __tablename__ = "ci_attributes"

    attr_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    attr_name = db.Column(db.String(32), nullable=False, unique=True)
    attr_alias = db.Column(db.String(32), nullable=False, unique=True)
    value_type = db.Column(
        db.Enum("int", "float", "text", "datetime", name='value_type'),
        default="text",
        nullable=False)
    is_choice = db.Column(db.Boolean, default=False)
    is_multivalue = db.Column(db.Boolean, default=False)
    is_uniq = db.Column(db.Boolean, default=False)
    is_index = db.Column(db.Boolean, default=False)


class IntegerChoice(db.Model):
    __tablename__ = 'choice_integers'

    choice_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    attr_id = db.Column(db.Integer,
                        db.ForeignKey('ci_attributes.attr_id'),
                        nullable=False)
    attr = db.relationship("CIAttribute", backref="choice_integers")
    value = db.Column(db.Integer, nullable=False)