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,
    )
Esempio n. 2
0
class UniquePotatoModel(ormar.Model):
    class Meta(BaseMeta):
        pass

    id = ormar.Integer(primary_key=True)
    thickness = ormar.Float()
    mass = ormar.Float()
    color = ormar.String(max_length=255, unique=True)
    type = ormar.String(max_length=255)
Esempio n. 3
0
class CustomPotatoModel(ormar.Model):
    class Meta(BaseMeta):
        tablename = "custom_potatoes"

    potato_id = ormar.Integer(primary_key=True)
    thickness = ormar.Float()
    mass = ormar.Float()
    color = ormar.String(max_length=255)
    type = ormar.String(max_length=255)
Esempio n. 4
0
class InvoicePosition(ormar.Model):
    class Meta(BaseMeta):
        tablename = "invoiceposition"

    id = ormar.Integer(primary_key=True)
    name = ormar.String(max_length=50)
    vat_rate_id = ormar.ForeignKey(VatRate)
    num_items = ormar.Float()
    price_net = ormar.Float()
    invoice_id = ormar.ForeignKey(Invoice, ondelete="CASCADE")
Esempio n. 5
0
class Organisation(ormar.Model):
    class Meta:
        tablename = "org"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    ident: str = ormar.String(max_length=100,
                              choices=["ACME Ltd", "Other ltd"])
    priority: int = ormar.Integer(choices=[1, 2, 3, 4, 5])
    priority2: int = ormar.BigInteger(choices=[1, 2, 3, 4, 5])
    expire_date: datetime.date = ormar.Date(
        choices=[datetime.date(2021, 1, 1),
                 datetime.date(2022, 5, 1)])
    expire_time: datetime.time = ormar.Time(
        choices=[datetime.time(10, 0, 0),
                 datetime.time(12, 30)])

    expire_datetime: datetime.datetime = ormar.DateTime(choices=[
        datetime.datetime(2021, 1, 1, 10, 0, 0),
        datetime.datetime(2022, 5, 1, 12, 30),
    ])
    random_val: float = ormar.Float(choices=[2.0, 3.5])
    random_decimal: decimal.Decimal = ormar.Decimal(
        scale=2,
        precision=4,
        choices=[decimal.Decimal(12.4),
                 decimal.Decimal(58.2)])
    random_json: pydantic.Json = ormar.JSON(choices=["aa", '{"aa":"bb"}'])
    random_uuid: uuid.UUID = ormar.UUID(choices=[uuid1, uuid2])
    enum_string: str = ormar.String(max_length=100, choices=list(EnumTest))
Esempio n. 6
0
class CarrotModel(ormar.Model):
    class Meta(BaseMeta):
        pass

    id = ormar.Integer(primary_key=True)
    length = ormar.Float()
    color = ormar.String(max_length=255)
Esempio n. 7
0
class VatRate(ormar.Model):
    class Meta(BaseMeta):
        tablename = "vatrate"

    id = ormar.Integer(primary_key=True)
    vat_rate = ormar.Float()
    comment = ormar.String(max_length=255)
    enterprise_id = ormar.ForeignKey(Enterprise, ondelete="CASCADE")
Esempio n. 8
0
class Product(ormar.Model):
    class Meta(BaseMeta):
        tablename = "product"

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    rating: float = ormar.Float(minimum=1, maximum=5)
    category = ormar.ForeignKey(Category)
Esempio n. 9
0
class Weather(ormar.Model):
    class Meta(MainMeta):
        pass

    id: int = ormar.Integer(primary_key=True)
    temperature: float = ormar.Float()
    icon: str = ormar.String(max_length=150)
    pub_date: datetime.datetime = ormar.DateTime(default=datetime.datetime.now)
Esempio n. 10
0
class Movie(ormar.Model):
    class Meta:
        tablename = "movies"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100, nullable=False, name="title")
    year: int = ormar.Integer()
    profit: float = ormar.Float()
    director: Optional[Director] = ormar.ForeignKey(Director)
Esempio n. 11
0
class Track(ormar.Model):
    """
    `tracks` table mapping.

    Attributes
    ----------
        id: str, primary key
        name: str
        href: str
        popularity: int, optional
        danceability: float, optional
        energy: float, optional
        loudness: float, optional
        speechiness: float, optional
        acousticness: float, optional
        instrumentalness: float, optional
        liveness: float, optional
        valence: float, optional
        tempo: float, optional
        key: int, optional
        mode: int, optional
        duration_ms: int, optional
        time_signature: int, optional
    """

    class Meta(BaseMeta):
        pass

    id: str = ormar.Text(primary_key=True)
    name: str = ormar.Text()
    href: str = ormar.Text()
    uri: str = ormar.Text()
    popularity: int = ormar.Integer()
    danceability: float = ormar.Float(nullable=True)
    energy: float = ormar.Float(nullable=True)
    loudness: float = ormar.Float(nullable=True)
    speechiness: float = ormar.Float(nullable=True)
    acousticness: float = ormar.Float(nullable=True)
    instrumentalness: float = ormar.Float(nullable=True)
    liveness: float = ormar.Float(nullable=True)
    valence: float = ormar.Float(nullable=True)
    tempo: float = ormar.Float(nullable=True)
    key: int = ormar.Integer(nullable=True)
    mode: int = ormar.Integer(nullable=True)
    duration_ms: int = ormar.Integer(nullable=True)
    time_signature: int = ormar.Integer(nullable=True)
Esempio n. 12
0
class Example(ormar.Model):
    class Meta:
        tablename = "example"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=200, default="aaa")
    created: datetime.datetime = ormar.DateTime(default=datetime.datetime.now)
    created_day: datetime.date = ormar.Date(default=datetime.date.today)
    created_time: datetime.time = ormar.Time(default=time)
    description: str = ormar.Text(nullable=True)
    value: float = ormar.Float(nullable=True)
    data: pydantic.Json = ormar.JSON(default={})
Esempio n. 13
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)