asyncqlio.orm.schema.column

Classes

AliasedColumn(…) Represents a column on an aliased table.
Column Represents a column in a table in a database.
class asyncqlio.orm.schema.column.AliasedColumn(alias_table: asyncqlio.orm.schema.table.AliasedTable, column: asyncqlio.orm.schema.column.Column)[source]

Bases: object

Represents a column on an aliased table.

Parameters:
  • alias_table – The alias table this column is a member of.
  • column – The Column object this aliased column proxies.
class asyncqlio.orm.schema.column.Column[source]

Bases: object

Represents a column in a table in a database.

class MyTable(Table):
    id = Column(Integer, primary_key=True)

The id column will mirror the ID of records in the table when fetching, etc. and can be set on a record when storing in a table.

sess = db.get_session()
user = await sess.select(User).where(User.id == 2).first()

print(user.id)  # 2
Parameters:
  • type – The ColumnType that represents the type of this column.
  • primary_key – Is this column the table’s Primary Key (the unique identifier that identifies each row)?
  • nullable – Can this column be NULL?
  • default – The client-side default for this column. If no value is provided when inserting, this value will automatically be added to the insert query.
  • autoincrement – Should this column auto-increment? This will create a serial sequence.
  • index – Should this column be indexed?
  • unique – Is this column unique?
  • foreign_key – The ForeignKey associated with this column.
name = None

The name of the column. This can be manually set, or automatically set when set on a table.

table = None

The Table instance this Column is associated with.

type = None

The ColumnType that represents the type of this column.

default = None

The default for this column.

primary_key = None

If this Column is a primary key.

nullable = None

If this Column is nullable.

autoincrement = None

If this Column is to autoincrement.

indexed = None

If this Column is indexed.

unique = None

If this Column is unique.

foreign_key = None

The foreign key associated with this column.

eq(other) → asyncqlio.orm.operators.Eq[source]

Checks if this column is equal to something else.

Note

This is the easy way to check if a column equals another column in a WHERE clause, because the default __eq__ behaviour returns a bool rather than an operator.

ne(other) → asyncqlio.orm.operators.NEq[source]

Checks if this column is not equal to something else.

Note

This is the easy way to check if a column doesn’t equal another column in a WHERE clause, because the default __ne__ behaviour returns a bool rather than an operator.

asc() → asyncqlio.orm.operators.AscSorter[source]

Returns the ascending sorter operator for this column.

desc() → asyncqlio.orm.operators.DescSorter[source]

Returns the descending sorter operator for this column.

set(value: typing.Any) → asyncqlio.orm.operators.ValueSetter[source]

Sets this column in a bulk update.

incr(value: typing.Any) → asyncqlio.orm.operators.IncrementSetter[source]

Increments this column in a bulk update.

decr(value: typing.Any) → asyncqlio.orm.operators.DecrementSetter[source]

Decrements this column in a bulk update.

quoted_fullname_with_table(table: asyncqlio.orm.schema.table.TableMeta) → str[source]

Gets the quoted fullname with a table. This is used for columns with alias tables.

Parameters:table – The Table or AliasedTable to use.
Returns:
quoted_name

Gets the quoted name for this column.

This returns the column name in “column” format.

quoted_fullname

Gets the full quoted name for this column.

This returns the column name in “table”.”column” format.

foreign_column
Returns:The foreign Column this is associated with, or None otherwise.
alias_name(table=None, quoted: bool = False) → str[source]

Gets the alias name for a column, given the table.

This is in the format of t_<table name>_<column_name>.

Parameters:
  • table – The Table to use to generate the alias name. This is useful for aliased tables.
  • quoted – Should the name be quoted?
Returns:

A str representing the alias name.