asyncpg_simpleorm.column package

Submodules

asyncpg_simpleorm.column.column_types module

class asyncpg_simpleorm.column.column_types.Array(_type, n=None, dimensions=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres ARRAY type.

Parameters:
  • _type – The type of the elements in the array. This would be another ColumnType subclass.
  • n – An optional int, that will make a sized array.
  • dimensions – An optional int that will create a dimensional array.

Example:

>>> Array(Integer()).pg_type_string
integer ARRAY
>>> Array(Integer(), 3).pg_type_string
integer ARRAY[3]
>>> Array(Integer(), 3, 3).pg_type_string
integer [3][3][3]
class asyncpg_simpleorm.column.column_types.BigInteger(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres int8 type.

class asyncpg_simpleorm.column.column_types.BigSerial(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres serial8 type.

class asyncpg_simpleorm.column.column_types.Binary(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres bytea type.

class asyncpg_simpleorm.column.column_types.Bit(n, fixed_length=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres bit or varbit type.

Parameters:
  • n – The number of bits.
  • fixed_length – An optional boolean. If True we will use bit(n). If False (default), we will use varbit(n).
class asyncpg_simpleorm.column.column_types.Boolean(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres bool type.

class asyncpg_simpleorm.column.column_types.Box(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres box type.

class asyncpg_simpleorm.column.column_types.Circle(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres circle type.

class asyncpg_simpleorm.column.column_types.Date(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres date type.

class asyncpg_simpleorm.column.column_types.DateRange(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres daterange type.

class asyncpg_simpleorm.column.column_types.Double(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres float8 type.

class asyncpg_simpleorm.column.column_types.FixedLengthString(n)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres char type.

Parameters:n (int) – The number of characters.
class asyncpg_simpleorm.column.column_types.IPAddress(inet=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres cidr or inet types.

Parameters:inet – An optional bool. If True then we will use inet. If False (default) then we use cidr.
class asyncpg_simpleorm.column.column_types.Integer(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres integer type.

class asyncpg_simpleorm.column.column_types.IntegerRange(big=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres int4range or int8range types.

Parameters:big – A boolean if True then will represent an int8range. If False (default) then we will use int4range.
class asyncpg_simpleorm.column.column_types.Json(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres json type.

class asyncpg_simpleorm.column.column_types.JsonB(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres jsonb type.

This is not supported by all postgres versions.

class asyncpg_simpleorm.column.column_types.Line(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres line type.

class asyncpg_simpleorm.column.column_types.LineSegment(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres lseg type.

class asyncpg_simpleorm.column.column_types.MACAddress(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres macaddr type.

class asyncpg_simpleorm.column.column_types.Money(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres money type.

class asyncpg_simpleorm.column.column_types.Number(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres numeric type.

class asyncpg_simpleorm.column.column_types.NumericRange(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres numrange type.

class asyncpg_simpleorm.column.column_types.PGLogSequenceNumber(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres pg_lsn type.

This is not supported by all postgres versions.

class asyncpg_simpleorm.column.column_types.Path(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres path type.

class asyncpg_simpleorm.column.column_types.Point(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres point type.

class asyncpg_simpleorm.column.column_types.Polygon(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres polygon type.

class asyncpg_simpleorm.column.column_types.Real(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres float4 type.

class asyncpg_simpleorm.column.column_types.Serial(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres serial4 type.

class asyncpg_simpleorm.column.column_types.SmallInteger(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres int2 type.

class asyncpg_simpleorm.column.column_types.SmallSerial(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres serial2 type.

class asyncpg_simpleorm.column.column_types.String(n=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres string column. Dependening on the context this will either produce a text column or varchar(n) column.

Parameters:n (Optional[int]) – An optional integer for the length of the string. If this is present then we use varchar(n), else we use text.
class asyncpg_simpleorm.column.column_types.TextSearchQuery(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres tsquery type.

class asyncpg_simpleorm.column.column_types.TextSearchVector(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres tsvector type.

class asyncpg_simpleorm.column.column_types.Time(with_timezone=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres time or timetz type.

Parameters:with_timezone (bool) – If True then it is time with timezone. If False (default) then it time without timezone.
class asyncpg_simpleorm.column.column_types.TimeInterval(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres interval type.

class asyncpg_simpleorm.column.column_types.Timestamp(with_timezone=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres timestamp or timestamptz type.

Parameters:with_timezone (bool) – If True then it is timestamp with timezone type. If False (default) then it timestamp without timezone type.
class asyncpg_simpleorm.column.column_types.TransactionID(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres txid_snapshot type.

class asyncpg_simpleorm.column.column_types.UUID(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres uuid type.

class asyncpg_simpleorm.column.column_types.XML(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres xml type.

Module contents

class asyncpg_simpleorm.column.Column(key=None, _type=None, *, default=None, primary_key=False)[source]

Bases: object

A descriptor class that represents a table column.

Parameters:
  • key (Optional[str]) – The table column name in the database. If not set, then this will be set to the attribute name used on the AsyncModel subclass the column was declared on.
  • type – The ColumnType subclass to use for the column.
  • default (Optional[Any]) – A value or callable that is used for a default value. If this is callable, then it should recieve no input and return a value when called.
  • primary_key (bool) – Set’s if the column is a primary key column. Primary key columns are used in certain query statements, such as AsyncModel.save()
default
key
pg_column_string
Return type:str
primary_key
class asyncpg_simpleorm.column.ColumnTypeABC(*args, **kwargs)[source]

Bases: object

Abstract representation of a postgres column type.

pg_type_string

Return the postgres type string.

Return type:str
class asyncpg_simpleorm.column.ColumnTypeMeta(*args, **kwargs)[source]

Bases: type

Ensures all ColumnType’s declare __slots__. If a subclass does not have an __init__ method, then this metaclass will add the __slots__ attribute.

Raises:RuntimeError – If subclass has an __init__ method and does not declare __slots__.
class asyncpg_simpleorm.column.ColumnType(string=None)[source]

Bases: object

Implementation of ColumnTypeABC.

This can be used as a generic column type, by passing a string into the constructor. That string will be used, else we will use a value that’s passed into the class declaration at pg_type_string.

Parameters:string (Optional[str]) – An optional input string that will be used for the column type. This string is not checked or validated, so if it’s not valid errors will bubble up when trying to create the table.

Examples:

>>> str(ColumnType('text'))
'text'
>>> class Text(ColumnType, pg_type_string='text'): pass
>>> str(Text())
'text'

Custom subclasses should implement __slots__. If they don’t need to set any attributes on the class (which is typically the case) and they derive from ColumnType then the __slots__ will be automatically added to the subclass.

pg_type_string

Return’s the postgres column type string for an instance.

Raises:TypeError – If neither an input string was passed in or pg_type_string in the class declaration.
Return type:str
class asyncpg_simpleorm.column.String(n=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres string column. Dependening on the context this will either produce a text column or varchar(n) column.

Parameters:n (Optional[int]) – An optional integer for the length of the string. If this is present then we use varchar(n), else we use text.
class asyncpg_simpleorm.column.UUID(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres uuid type.

class asyncpg_simpleorm.column.Boolean(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres bool type.

class asyncpg_simpleorm.column.Integer(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres integer type.

class asyncpg_simpleorm.column.Number(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres numeric type.

class asyncpg_simpleorm.column.Date(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres date type.

class asyncpg_simpleorm.column.Time(with_timezone=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres time or timetz type.

Parameters:with_timezone (bool) – If True then it is time with timezone. If False (default) then it time without timezone.
class asyncpg_simpleorm.column.Timestamp(with_timezone=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres timestamp or timestamptz type.

Parameters:with_timezone (bool) – If True then it is timestamp with timezone type. If False (default) then it timestamp without timezone type.
class asyncpg_simpleorm.column.TimeInterval(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres interval type.

class asyncpg_simpleorm.column.Bit(n, fixed_length=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres bit or varbit type.

Parameters:
  • n – The number of bits.
  • fixed_length – An optional boolean. If True we will use bit(n). If False (default), we will use varbit(n).
class asyncpg_simpleorm.column.BigInteger(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres int8 type.

class asyncpg_simpleorm.column.Array(_type, n=None, dimensions=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres ARRAY type.

Parameters:
  • _type – The type of the elements in the array. This would be another ColumnType subclass.
  • n – An optional int, that will make a sized array.
  • dimensions – An optional int that will create a dimensional array.

Example:

>>> Array(Integer()).pg_type_string
integer ARRAY
>>> Array(Integer(), 3).pg_type_string
integer ARRAY[3]
>>> Array(Integer(), 3, 3).pg_type_string
integer [3][3][3]
class asyncpg_simpleorm.column.BigSerial(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres serial8 type.

class asyncpg_simpleorm.column.Binary(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres bytea type.

class asyncpg_simpleorm.column.FixedLengthString(n)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres char type.

Parameters:n (int) – The number of characters.
class asyncpg_simpleorm.column.Money(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres money type.

class asyncpg_simpleorm.column.IPAddress(inet=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres cidr or inet types.

Parameters:inet – An optional bool. If True then we will use inet. If False (default) then we use cidr.
class asyncpg_simpleorm.column.MACAddress(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres macaddr type.

class asyncpg_simpleorm.column.Box(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres box type.

class asyncpg_simpleorm.column.Line(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres line type.

class asyncpg_simpleorm.column.LineSegment(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres lseg type.

class asyncpg_simpleorm.column.Circle(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres circle type.

class asyncpg_simpleorm.column.Path(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres path type.

class asyncpg_simpleorm.column.Point(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres point type.

class asyncpg_simpleorm.column.Polygon(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres polygon type.

class asyncpg_simpleorm.column.Double(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres float8 type.

class asyncpg_simpleorm.column.Json(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres json type.

class asyncpg_simpleorm.column.JsonB(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres jsonb type.

This is not supported by all postgres versions.

class asyncpg_simpleorm.column.PGLogSequenceNumber(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres pg_lsn type.

This is not supported by all postgres versions.

class asyncpg_simpleorm.column.Real(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres float4 type.

class asyncpg_simpleorm.column.SmallInteger(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres int2 type.

class asyncpg_simpleorm.column.SmallSerial(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres serial2 type.

class asyncpg_simpleorm.column.Serial(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres serial4 type.

class asyncpg_simpleorm.column.TextSearchQuery(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres tsquery type.

class asyncpg_simpleorm.column.TextSearchVector(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres tsvector type.

class asyncpg_simpleorm.column.TransactionID(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres txid_snapshot type.

class asyncpg_simpleorm.column.XML(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres xml type.

class asyncpg_simpleorm.column.IntegerRange(big=False)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres int4range or int8range types.

Parameters:big – A boolean if True then will represent an int8range. If False (default) then we will use int4range.
class asyncpg_simpleorm.column.NumericRange(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres numrange type.

class asyncpg_simpleorm.column.DateRange(string=None)[source]

Bases: asyncpg_simpleorm.column.base_column_type.ColumnType

Representation of postgres daterange type.