Classes for column objects.
Classes
AliasedColumn (alias_table, column) |
Represents a column on an aliased table. |
Column (type_, *[, primary_key, nullable, …]) |
Represents a column in a table in a database. |
asyncqlio.orm.schema.column.
AliasedColumn
(alias_table, column)[source]¶Bases: object
Represents a column on an aliased table.
Parameters: |
|
---|
asyncqlio.orm.schema.column.
Column
(type_, *, primary_key=False, nullable=False, default=<object object>, index=True, unique=False, foreign_key=None, table=None)[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: |
|
---|
name
= None¶The name of the column. This can be manually set, or automatically set when set on a table.
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.
indexed
= None¶If this Column is indexed.
unique
= None¶If this Column is unique.
foreign_key
= None¶The foreign key associated with this column.
with_name
(name, *args, **kwargs)[source]¶Creates this column with a name already set.
Return type: | Column |
---|
eq
(other)[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.
Return type: | Eq |
---|
ne
(other)[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.
Return type: | NEq |
---|
desc
()[source]¶Returns the descending sorter operator for this column.
Return type: | DescSorter |
---|
set
(value)[source]¶Sets this column in a bulk update.
Return type: | ValueSetter |
---|
incr
(value)[source]¶Increments this column in a bulk update.
Return type: | IncrementSetter |
---|
decr
(value)[source]¶Decrements this column in a bulk update.
Return type: | DecrementSetter |
---|
quoted_fullname_with_table
(table)[source]¶Gets the quoted fullname with a table. This is used for columns with alias tables.
Parameters: | table (TableMeta ) – The Table or AliasedTable to use. |
---|---|
Return type: | str |
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
¶Return type: | Column |
---|---|
Returns: | The foreign Column this is associated with, or None otherwise. |