Powered by Tachyonic Project Luxon Framework v0.0.0

Luxon Framework for rapid application development. (luxon)

Version

Models - ORM

A model is the data structure of information. It contains the fields, types and restrictions of the data you’re storing. A model can map to a single database table.

The basics:

  • Each model is a Python class that subclasses luxon.models or luxon.model
  • luxon.model is for a single object with fields.
  • luxon.models contains list/rows of objects with fields.
  • Using models optionally gives you conveniantly maintained and generated database.

The luxon command line tool provides an option luxon -d to create or update database schema. However it requires the application root to have a correctly configured settings.ini with relevant database configuration.

Warning:
Please backup your database before updating the schema.

While working with a ‘models’ object you can iterate, update rows and so forth. It behaves a like a list data structure with ‘model’ objects that behave like a dictionary of columns/fields. The rollback and commit can be used without database.

Using models with database require you to define Primary Key using ‘primary_key’ class attribute. Its a reference to relevant field.

Note:
To use a model with database you will need to decorate it with luxon.database ‘Integer’ type fields as primary_key will automatically increment. However auto increment is only relevant when using database.

Example

from uuid import uuid4

from luxon import register
from luxon import SQLModel
from luxon.utils.timezone import now

-------------------------------------------------
# Model for roles
-------------------------------------------------

ROLES = [
    ('00000000-0000-0000-0000-000000000000', 'Root', None, now()),
    (str(uuid4()), 'Operations', None, now()),
    (str(uuid4()), 'Administrator', None, now()),
    (str(uuid4()), 'Account Manager', None, now()),
    (str(uuid4()), 'Billing', None, now()),
    (str(uuid4()), 'Support', None, now()),
    (str(uuid4()), 'Customer', None, now()),
    (str(uuid4()), 'Wholesale', None, now()),
    (str(uuid4()), 'Minion', None, now()),
]

@register.model()
class luxon_role(SQLModel):
    id = SQLModel.Uuid(default=uuid4, internal=True)
    name = SQLModel.String(max_length=64, null=False)
    description = SQLModel.Text()
    creation_time = SQLModel.DateTime(default=now, readonly=True)
    primary_key = id
    unique_role = SQLModel.UniqueIndex(name)
    db_default_rows = ROLES
    roles = SQLModel.Index(name)

-------------------------------------------------
# Model for domains
-------------------------------------------------

DOMAINS = [
    ('00000000-0000-0000-0000-000000000000', 'default', None, 1, now()),
]

@register.model()
class luxon_domain(SQLModel):
    id = SQLModel.Uuid(default=uuid4, internal=True)
    name = SQLModel.Fqdn(null=False)
    description = SQLModel.Text()
    enabled = SQLModel.Boolean(default=True)
    creation_time = SQLModel.DateTime(default=now, readonly=True)
    primary_key = id
    unique_domain = SQLModel.UniqueIndex(name)
    db_default_rows = DOMAINS
    domains = SQLModel.Index(name)

-------------------------------------------------
# Model for tennants
-------------------------------------------------

@register.model()
class luxon_tenant(SQLModel):
    id = SQLModel.Uuid(default=uuid4, internal=True)
    domain = SQLModel.Fqdn(internal=True)
    tenant_id = SQLModel.Uuid(internal=True)
    name = SQLModel.String(max_length=100, null=False)
    enabled = SQLModel.Boolean(default=True)
    creation_time = SQLModel.DateTime(default=now, readonly=True)
    unique_tenant = SQLModel.UniqueIndex(domain, name)
    tenants = SQLModel.Index(id, domain)
    tenants_search_name = SQLModel.Index(domain, name)
    tenants_per_domain = SQLModel.Index(domain)
    primary_key = id
    tenant_domain_ref = SQLModel.ForeignKey(domain, luxon_domain.name)
    tenant_parent_ref = SQLModel.ForeignKey(tenant_id, id)

----------------------------------------------------
# Model for users
----------------------------------------------------

USERS = [
    ('00000000-0000-0000-0000-000000000000', 'tachyonic',
     None, None,
     'root', '$2b$12$QaWa.Q3gZuafYXkPo3EJRuSJ1wGuutShb73RuH1gdUVri82CU6V5q',
     None, 'Default Root User', None, None, None, None,
     1, now()),
]


@register.model()
class luxon_user(SQLModel):
    id = SQLModel.Uuid(default=uuid4, internal=True)
    tag = SQLModel.String(hidden=True, max_length=30, null=False)
    domain = SQLModel.Fqdn(internal=True)
    tenant_id = SQLModel.Uuid(internal=True)
    username = SQLModel.Username(max_length=100, null=False)
    password = SQLModel.String(max_length=100, null=True)
    email = SQLModel.Email(max_length=255)
    name = SQLModel.String(max_length=100)
    phone_mobile = SQLModel.Phone()
    phone_office = SQLModel.Phone()
    designation = SQLModel.Enum('', 'Mr', 'Mrs', 'Ms', 'Dr', 'Prof')
    last_login = SQLModel.DateTime(readonly=True)
    enabled = SQLModel.Boolean(default=True)
    creation_time = SQLModel.DateTime(default=now, readonly=True)
    unique_username = SQLModel.UniqueIndex(domain, username)
    user_tenant_ref = SQLModel.ForeignKey(tenant_id, luxon_tenant.id)
    user_domain_ref = SQLModel.ForeignKey(domain, luxon_domain.name)
    users = SQLModel.Index(domain, username)
    users_tenants = SQLModel.Index(domain, tenant_id)
    users_domain = SQLModel.Index(domain)
    primary_key = id
    db_default_rows = USERS

----------------------------------------------------
# Model for user roles
----------------------------------------------------


USER_ROLES = [
    ('00000000-0000-0000-0000-000000000000',
     '00000000-0000-0000-0000-000000000000',
     None,
     None,
     '00000000-0000-0000-0000-000000000000',
     now()),
]

@register.model()
class luxon_user_role(SQLModel):
    id = SQLModel.Uuid(default=uuid4, internal=True)
    role_id = SQLModel.Uuid()
    domain = SQLModel.Fqdn(internal=True)
    tenant_id = SQLModel.String()
    user_id = SQLModel.Uuid()
    creation_time = SQLModel.DateTime(readonly=True, default=now)
    unique_user_role = SQLModel.UniqueIndex(role_id, tenant_id, user_id)
    user_role_id_ref = SQLModel.ForeignKey(role_id, luxon_role.id)
    user_role_domain_ref = SQLModel.ForeignKey(domain, luxon_domain.name)
    user_role_tenant_ref = SQLModel.ForeignKey(tenant_id, luxon_tenant.id)
    user_roles = SQLModel.Index(domain, tenant_id)
    primary_key = id
    db_default_rows = USER_ROLES

Model base Class

class luxon.Model(hide=None)[source]
commit()[source]

Commit transaction.

dict

Return as raw dict.

json

Return as serialized JSON.

new()[source]

Create new row.

Creates a new row and returns row model.

rollback()[source]

Rollback.

Rollback to previous state before commit.

transaction

Return current state.

update(obj)[source]

Update Models.

Append (list) or Update (obj) object to columns.

Parameters:obj (list/dict) – List / Dict Object.

model Fields

Data types supported by Luxon models

Conveniantly accessible using ‘model_name.field_name’

Base Fields

class luxon.structs.models.fields.basefields.BaseFields[source]

Base Fields outer class

class BaseField(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

Field Class.

Provides abstractions for most common database data types.

Keyword Arguments:
 
  • length (int) – Length of field value.
  • min_length (int) – Minimum Length of field value.
  • max_length (int) – Maximum Length of field value others length value.
  • signed (bool) – If Integer value is signed or un-signed.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • columns (int) – Number of columns to display for text field.
  • hidden (bool) – To hide field from forms.
  • enum (list) – List of possible values. Only for ENUM.
class Confirm(field)[source]
class DateTime(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

DateTime Field.

Accepts datetime values from strings and datetime objects.

Supports timezones and naive, however all datetimes are converted to UTC/GMT +00:00.

class Decimal(m, d)[source]

Decimal Field.

For values which are “naturally exact decimals” it’s good to use decimal. This is usually suitable for any concepts invented by humans: financial values are the most obvious example, but there are others too. Consider the score given to divers or ice skaters, for example.

Keep in mind in SQLite this is REAL numbers with double floating points.

Keyword Arguments:
 
  • m (int) – Values can be stored with up to M digits in total.
  • d (int) – Digits that may be after the decimal point.
class Double(m, d)[source]

Double Field.

The DOUBLE type represent approximate numeric data values. MySQL uses eight bytes for double-precision values. Keep in mind SQLLite uses REAL numbers with double floating points.

For values which are more artefacts of nature which can’t really be measured exactly anyway, float/double are more appropriate. For example, scientific data would usually be represented in this form. Here, the original values won’t be “decimally accurate” to start with, so it’s not important for the expected results to maintain the “decimal accuracy”. Floating binary point types are much faster to work with than decimals.

Doubles provide more accuracy vs floats. However in Python floats are doubles.

Keyword Arguments:
 
  • m (int) – Values can be stored with up to M digits in total.
  • d (int) – Digits that may be after the decimal point.
class Email(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

Email Field.

class Enum(*args, **kwargs)[source]

Enum Field.

An ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation time.

Provide arguements as individual permitted values.

class Float(m, d)[source]

Float Field.

The FLOAT type represent approximate numeric data values. MySQL uses four bytes for single-precision values. Keep in mind SQLLite uses REAL numbers with double floating points.

For values which are more artefacts of nature which can’t really be measured exactly anyway, float/double are more appropriate. For example, scientific data would usually be represented in this form. Here, the original values won’t be “decimally accurate” to start with, so it’s not important for the expected results to maintain the “decimal accuracy”. Floating binary point types are much faster to work with than decimals.

Keyword Arguments:
 
  • m (int) – Values can be stored with up to M digits in total.
  • d (int) – Digits that may be after the decimal point.
class Fqdn(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

FQDN Field.

class Phone(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

Phone Number Field.

class PyObject[source]

Python Object Field.

This object cannot be stored in database, however can be any object within python.

class String(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

String Field.

Keyword Arguments:
 
  • length (int) – Length of field value.
  • min_length (int) – Minimum Length of field value.
  • max_length (int) – Maximum Length of field value others length value.
  • columns (int) – Number of columns to display for text field.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class Uri(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

URI Field.

class Username(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

Username Field.

class Uuid(**kwargs)[source]

UUID Field.

For example: 827C7CCC-F9BD-47AC-A674-ABBBED665008

class Word(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True, internal=False, ignore_null=False)[source]

Blob Fields

class luxon.structs.models.fields.blobfields.BlobFields[source]

Blob Fields outer class

class BaseBlob(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Blob Field.

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class Blob(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Blob Field.

64 KB field 65535 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class LongBlob(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Long Blob Field.

4 GB field 4294967295 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class MediumBlob(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Medium Blob Field.

16 MB field 16777215 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class TinyBlob(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Tiny Blob Field.

255 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.

Int Fields

class luxon.structs.models.fields.intfields.IntFields[source]

Int Fields outer class

class BaseInteger(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True)[source]

Integer Field.

Keyword Arguments:
 
  • length (int) – Length of field value.
  • min_length (int) – Minimum Length of field value.
  • max_length (int) – Maximum Length of field value others length value.
  • signed (bool) – If Integer value is signed or un-signed.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class BigInt(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True)[source]

Big Integer Field.

4 Octet Integer Minimum value -9223372036854775808 Maximum value 9223372036854775807

Keyword Arguments:
 
  • length (int) – Length of field value.
  • min_length (int) – Minimum Length of field value.
  • max_length (int) – Maximum Length of field value others length value.
  • signed (bool) – If Integer value is signed or un-signed.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class Boolean(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True)[source]

Boolean Field.

class Integer(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True)[source]

Integer Field.

4 Octet Integer Minimum value -2147483648 Maximum value 2147483647

Keyword Arguments:
 
  • length (int) – Length of field value.
  • signed (bool) – If Integer value is signed or un-signed.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class MediumInt(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True)[source]

Medium Integer Field.

3 Octet Integer Minimum value -8388608 Maximum value 8388607

Keyword Arguments:
 
  • length (int) – Length of field value.
  • signed (bool) – If Integer value is signed or un-signed.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class SmallInt(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True)[source]

Small Integer Field.

2 Octet Integer Minimum value -32768 Maximum value 32767

Keyword Arguments:
 
  • length (int) – Length of field value.
  • signed (bool) – If Integer value is signed or un-signed.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class TinyInt(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False, signed=True)[source]

Tiny Integer Field.

1 Octet Integer Minimum value -128 Maximum value 127

Keyword Arguments:
 
  • length (int) – Length of field value.
  • signed (bool) – If Integer value is signed or un-signed.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.

Sql Fields

class luxon.structs.models.fields.sqlfields.SQLFields[source]

SQL Fields outer class

class ForeignKey(foreign_keys, reference_fields, on_delete='CASCADE', on_update='CASCADE')[source]

Foreign Key.

Foreign Keys let you cross-reference related data across tables, and foreign key constraints, which help keep this spread-out data consistent.

SQLLite3 + MySQL support this functionality.

Parameters:
  • forgein_keys (list) – List values should be reference to fields within this model.
  • reference_fields (list) – List values should be reference to fields within the remote table in same order as per foreign_keys.
  • on_delete (str) – Delete action affecting foreign key row. default ‘cascade’
  • on_update (str) – Update action affecting foreign key row. default ‘cascade’
Valid values for actions:
  • NO ACTION: Configuring “NO ACTION” means just that: when a parent key
    is modified or deleted from the database, no action is taken.
  • RESTRICT: The “RESTRICT” action means that the application is
    prohibited from deleting (for ON DELETE RESTRICT) or modifying (for ON UPDATE RESTRICT) a parent key if there exists one or more child keys mapped to it. The difference between the effect of a RESTRICT action and normal foreign key constraint enforcement is that the RESTRICT action processing happens as soon as the field is updated - not at the end of the current statement as it would with an immediate constraint, or at the end of the current transaction as it would with a deferred Even if the foreign key constraint it is attached to is deferred, configuring a RESTRICT action causes to return an error immediately if a parent key with dependent child keys is deleted or modified.
  • SET NULL: If the configured action is “SET NULL”, then when a parent
    key is deleted (for ON DELETE SET NULL) or modified (for ON UPDATE SET NULL), the child key columns of all rows in the child table that mapped to the parent key are set to contain SQL NULL values.
  • SET DEFAULT: The “SET DEFAULT” actions are similar to “SET NULL”,
    except that each of the child key columns is set to contain the columns default value instead of NULL.
  • CASCADE: A “CASCADE” action propagates the delete or update operation
    on the parent key to each dependent child key. For an “ON DELETE CASCADE” action, this means that each row in the child table that was associated with the deleted parent row is also deleted. For an “ON UPDATE CASCADE” action, it means that the values stored in each dependent child key are modified to match the new parent values.
class Index(*args)[source]

Index.

Indexes are used to find rows with specific column values quickly. Without an index, SQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, SQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. This is much faster than reading every row sequentially.

Provide arguements as individual permitted fields. These should be reference to another model field.

SQLLite3 + MySQL support this functionality.

class UniqueIndex(*args)[source]

Unique Index.

UNIQUE refers to an index where all rows of the index must be unique. That is, the same row may not have identical non-NULL values for all columns in this index as another row. As well as being used to speed up queries, UNIQUE indexes can be used to enforce restraints on data, because the database system does not allow this distinct values rule to be broken when inserting or updating data.

Provide arguements as individual permitted fields. These should be reference to another model field.

SQLLite3 + MySQL support this functionality.

Text Fields

class luxon.structs.models.fields.textfields.TextFields[source]

Text Fields outer class

class BaseText(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Text Field.

64 KB field 65535 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class LongText(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Long Text Field.

4 GB field 4294967295 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class MediumText(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Medium Text Field.

16 MB field 16777215 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class Text(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Text Field.

64 KB field 65535 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.
class TinyText(length=None, min_length=None, max_length=None, null=True, default=None, db=True, label=None, placeholder=None, readonly=False, prefix=None, suffix=None, columns=None, hidden=False, enum=[], on_update=None, password=False)[source]

Tiny Text Field.

255 Octets

Keyword Arguments:
 
  • length (int) – Length of field value.
  • null (bool) – If value is allowed to NULL.
  • default – Default value for field.
  • on_update – Default value for field on update..
  • db (bool) – Whether to store value in db column.
  • label (str) – Human friendly name for field.
  • placeholder (str) – Example to display in field.
  • readonly (bool) – Whether field can be updated.
  • prefix (str) – Text placed in front of field input.
  • suffix (str) – Text placed after field input.
  • hidden (bool) – To hide field from forms.