コード例 #1
0
ファイル: ormar.py プロジェクト: shalevy1/fastapi-users
class OrmarBaseUserModel(ormar.Model):
    class Meta:
        tablename = "users"
        abstract = True

    id = ormar.UUID(primary_key=True, uuid_format="string")
    email = ormar.String(index=True, unique=True, nullable=False, max_length=255)
    hashed_password = ormar.String(nullable=False, max_length=255)
    is_active = ormar.Boolean(default=True, nullable=False)
    is_superuser = ormar.Boolean(default=False, nullable=False)
    is_verified = ormar.Boolean(default=False, nullable=False)
コード例 #2
0
class User(ormar.Model):
    class Meta(MainMata):
        pass

    id: int = ormar.Integer(primary_key=True)
    username: str = ormar.String(max_length=100, unique=True)
    phone: str = ormar.String(max_length=14, unique=True, nullable=True)
    email = ormar.String(index=True,
                         unique=True,
                         nullable=False,
                         max_length=255)
    avatar = ormar.String(max_length=500, nullable=True)
    is_active = ormar.Boolean(default=True, nullable=False)
    is_superuser = ormar.Boolean(default=False, nullable=False)
コード例 #3
0
class Filter(ormar.Model):
    class Meta(ormar.ModelMeta):
        tablename = "filters"
        database = database
        metadata = metadata

    filter_id = ormar.Integer(primary_key=True, autoincrement=True)
    name = ormar.String(max_length=200, unique=True, index=True)
    label = ormar.String(max_length=200)
    query_text = ormar.Text()
    allow_multiselect = ormar.Boolean(default=True)
    created_date = ormar.DateTime(server_default=func.now())
    is_dynamic = ormar.Boolean(default=True)
    is_date = ormar.Boolean(default=False)
    translation = ormar.ForeignKey(TranslationNode, name="translation_node_id")
コード例 #4
0
class Author(ormar.Model):
    class Meta(BaseMeta):
        tablename = "authors"

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100, **default_fernet)
    uuid_test = ormar.UUID(default=uuid.uuid4, uuid_format="string")
    uuid_test2 = ormar.UUID(nullable=True, uuid_format="string")
    password: str = ormar.String(
        max_length=128,
        encrypt_secret="udxc32",
        encrypt_backend=ormar.EncryptBackends.HASH,
    )
    birth_year: int = ormar.Integer(
        nullable=True,
        encrypt_secret="secure89key%^&psdijfipew",
        encrypt_backend=ormar.EncryptBackends.FERNET,
    )
    test_text: str = ormar.Text(default="", **default_fernet)
    test_bool: bool = ormar.Boolean(nullable=False, **default_fernet)
    test_float: float = ormar.Float(**default_fernet)
    test_float2: float = ormar.Float(nullable=True, **default_fernet)
    test_datetime = ormar.DateTime(default=datetime.datetime.now, **default_fernet)
    test_date = ormar.Date(default=datetime.date.today, **default_fernet)
    test_time = ormar.Time(default=datetime.time, **default_fernet)
    test_json = ormar.JSON(default={}, **default_fernet)
    test_bigint: int = ormar.BigInteger(default=0, **default_fernet)
    test_decimal = ormar.Decimal(scale=2, precision=10, **default_fernet)
    test_decimal2 = ormar.Decimal(max_digits=10, decimal_places=2, **default_fernet)
    custom_backend: str = ormar.String(
        max_length=200,
        encrypt_secret="asda8",
        encrypt_backend=ormar.EncryptBackends.CUSTOM,
        encrypt_custom_backend=DummyBackend,
    )
コード例 #5
0
class User(ormar.Model):
    class Meta(BaseMeta):
        tablename = "users"

    id: int = ormar.Integer(primary_key=True)
    email: str = ormar.String(max_length=128, unique=True, nullable=False)
    active: bool = ormar.Boolean(default=True, nullable=False)
コード例 #6
0
class NickNames(ormar.Model):
    class Meta(BaseMeta):
        tablename = "nicks"

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100, nullable=False, name="hq_name")
    is_lame: bool = ormar.Boolean(nullable=True)
コード例 #7
0
class Task(ormar.Model):
    class Meta(BaseMeta):
        tablename = "tasks"
        orders_by = ["-id"]

    id: int = ormar.Integer(primary_key=True, unique=True)
    name: str = ormar.String(max_length=100)
    completed: bool = ormar.Boolean(default=False)
コード例 #8
0
ファイル: docs004.py プロジェクト: tillspeicher/ormar
class Course(ormar.Model):
    class Meta(ormar.ModelMeta):  # note you don't have to subclass - but it's recommended for ide completion and mypy
        database = database
        metadata = metadata

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    completed: bool = ormar.Boolean(default=False)
コード例 #9
0
ファイル: docs011.py プロジェクト: tillspeicher/ormar
class Course(ormar.Model):
    class Meta:
        database = database
        metadata = metadata

    id: ormar.Integer(primary_key=True)
    name: ormar.String(max_length=100)
    completed: ormar.Boolean(default=False)
コード例 #10
0
ファイル: docs002.py プロジェクト: tillspeicher/ormar
class Course(ormar.Model):
    class Meta:
        database = database
        metadata = metadata

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    completed: bool = ormar.Boolean(default=False)
    department: Optional[Department] = ormar.ForeignKey(Department, related_name="my_courses")
コード例 #11
0
ファイル: test_foreign_keys.py プロジェクト: h0rn3t/ormar
class Album(ormar.Model):
    class Meta:
        tablename = "albums"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    is_best_seller: bool = ormar.Boolean(default=False)
コード例 #12
0
ファイル: models.py プロジェクト: Alex-Evo-2266/SmartHome
class User(ormar.Model):
    class Meta(BaseMeta):
        pass

    id: int = ormar.Integer(primary_key=True)
    UserName: str = ormar.String(max_length=200, nullable=False)
    UserSurname: str = ormar.String(max_length=200, nullable=True)
    UserPassword: str = ormar.String(max_length=200, nullable=False)
    UserEmail: str = ormar.String(max_length=200, nullable=False)
    UserMobile: str = ormar.String(max_length=200, nullable=False)
    UserLevel: int = ormar.Integer(default=1)
    Style: str = ormar.String(max_length=200, default="light")
    auteStyle: bool = ormar.Boolean(default=True)
    staticBackground: bool = ormar.Boolean(default=False)
    page: str = ormar.String(max_length=200, default="basePage")

    def __str__(self):
        return self.UserName
コード例 #13
0
class ToDo(ormar.Model):
    class Meta:
        tablename = "todos"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    text: str = ormar.String(max_length=500)
    completed: bool = ormar.Boolean(default=False)
コード例 #14
0
class NickName(ormar.Model):
    class Meta:
        tablename = "nicks"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100, nullable=False, name="hq_name")
    is_lame: bool = ormar.Boolean(nullable=True)
    level: CringeLevel = ormar.ForeignKey(CringeLevel)
コード例 #15
0
ファイル: test_models.py プロジェクト: EspenAlbert/ormar
class Product(ormar.Model):
    class Meta:
        tablename = "product"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    rating: int = ormar.Integer(minimum=1, maximum=5)
    in_stock: bool = ormar.Boolean(default=False)
    last_delivery: datetime.date = ormar.Date(default=datetime.datetime.now)
コード例 #16
0
ファイル: test_signals.py プロジェクト: tillspeicher/ormar
class Album(ormar.Model):
    class Meta:
        tablename = "albums"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    is_best_seller: bool = ormar.Boolean(default=False)
    play_count: int = ormar.Integer(default=0)
    cover: Optional[Cover] = ormar.ForeignKey(Cover)
コード例 #17
0
ファイル: docs002.py プロジェクト: tillspeicher/ormar
class Course(ormar.Model):
    class Meta:
        # if you omit this parameter it will be created automatically
        # as class.__name__.lower()+'s' -> "courses" in this example
        tablename = "my_courses"
        database = database
        metadata = metadata

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    completed: bool = ormar.Boolean(default=False)
コード例 #18
0
ファイル: test_uuid_fks.py プロジェクト: tillspeicher/ormar
class User(ormar.Model):
    class Meta:
        tablename = "user"
        metadata = metadata
        database = db

    id: uuid.UUID = ormar.UUID(primary_key=True,
                               default=uuid.uuid4,
                               uuid_format="string")
    username = ormar.String(index=True,
                            unique=True,
                            null=False,
                            max_length=255)
    email = ormar.String(index=True,
                         unique=True,
                         nullable=False,
                         max_length=255)
    hashed_password = ormar.String(null=False, max_length=255)
    is_active = ormar.Boolean(default=True, nullable=False)
    is_superuser = ormar.Boolean(default=False, nullable=False)
コード例 #19
0
class LicenseAccount(ormar.Model):
    """
    Describe `LicenseAccount` model in database
    """
    class Meta(BaseMeta):
        # pylint:disable=(missing-class-docstring)
        pass

    id: int = ormar.Integer(primary_key=True)
    email: EmailStr = ormar.String(max_length=45)
    is_using: bool = ormar.Boolean(default=False)
コード例 #20
0
class Course(ormar.Model):
    class Meta:
        database = database
        metadata = metadata

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    completed: bool = ormar.Boolean(default=False)

    @property_field
    def prefixed_name(self):
        return 'custom_prefix__' + self.name
コード例 #21
0
ファイル: claim.py プロジェクト: stake-house/poap-reddit-bot
class Claim(ormar.Model):
    class Meta(BaseMeta):
        tablename = "claims"
        constraints = [ormar.UniqueColumns('attendee', 'event')]

    id: int = ormar.Integer(primary_key=True)
    attendee: Attendee = ormar.ForeignKey(Attendee,
                                          nullable=True,
                                          skip_reverse=True)
    event: Event = ormar.ForeignKey(Event, skip_reverse=True)
    link: str = ormar.String(max_length=256)
    reserved: Optional[bool] = ormar.Boolean(default=False)
コード例 #22
0
class Course(ormar.Model):
    class Meta:
        database = database
        metadata = metadata
        # define your constraints in Meta class of the model
        # it's a list that can contain multiple constraints
        # hera a combination of name and column will have to be unique in db
        constraints = [ormar.UniqueColumns("name", "completed")]

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    completed: bool = ormar.Boolean(default=False)
コード例 #23
0
class Contact(ormar.Model):
    class Meta(MainMeta):
        pass

    id: int = ormar.Integer(primary_key=True)
    title: str = ormar.String(max_length=150)
    face: str = ormar.String(max_length=150)
    phone: str = ormar.String(max_length=15)
    date: datetime.datetime = ormar.DateTime(default=datetime.datetime.now())
    email: str = ormar.String(max_length=100)
    message: str = ormar.String(max_length=100)
    checked: bool = ormar.Boolean(default=False)
コード例 #24
0
class FilterXReport(ormar.Model):
    class Meta(ormar.ModelMeta):
        tablename = "filters_x_reports"
        database = database
        metadata = metadata

    filter_x_report_id = ormar.Integer(primary_key=True)
    filter = ormar.ForeignKey(Filter, name="filter_id", related_name="reports")
    report = ormar.ForeignKey(Report, name="report_id", related_name="filters")
    sort_order = ormar.Integer()
    default_value = ormar.Text()
    is_visible = ormar.Boolean()
コード例 #25
0
ファイル: test_models.py プロジェクト: paolodina/ormar
class Country(ormar.Model):
    class Meta:
        tablename = "country"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(
        max_length=9, choices=country_name_choices, default="Canada",
    )
    taxed: bool = ormar.Boolean(choices=country_taxed_choices, default=True)
    country_code: int = ormar.Integer(
        minimum=0, maximum=1000, choices=country_country_code_choices, default=1
    )
コード例 #26
0
class ExampleModel(Model):
    class Meta:
        tablename = "example"
        metadata = metadata

    test: int = ormar.Integer(primary_key=True)
    test_string: str = ormar.String(max_length=250)
    test_text: str = ormar.Text(default="")
    test_bool: bool = ormar.Boolean(nullable=False)
    test_float: ormar.Float() = None  # type: ignore
    test_datetime = ormar.DateTime(default=datetime.datetime.now)
    test_date = ormar.Date(default=datetime.date.today)
    test_time = ormar.Time(default=datetime.time)
    test_json = ormar.JSON(default={})
    test_bigint: int = ormar.BigInteger(default=0)
    test_decimal = ormar.Decimal(scale=2, precision=10)
    test_decimal2 = ormar.Decimal(max_digits=10, decimal_places=2)
コード例 #27
0
class Meeting(ormar.Model):
    """
    Describe `Meeting` model in database
    """
    class Meta(BaseMeta):
        # pylint:disable=(missing-class-docstring)
        pass

    id: int = ormar.Integer(primary_key=True)
    meeting_id: str = ormar.String(max_length=70)
    title: str = ormar.String(max_length=70)
    calendar_id: str = ormar.String(max_length=150, nullable=True)
    event_id: str = ormar.String(max_length=150, nullable=True)
    course_code: str = ormar.String(max_length=150, nullable=True)
    start_url: str = ormar.String(max_length=1000)
    join_url: str = ormar.String(max_length=100)
    is_active: bool = ormar.Boolean(default=True)
    created: datetime = ormar.DateTime(default=datetime.now())
    email: LicenseAccount = ormar.ForeignKey(LicenseAccount)