types - columns data types

class CITEXT[source]

Postgres case-insensitive text data type.

__init__(length: int | None = None, collation: str | None = None)

Create a string-holding type.

Parameters:
  • length – optional, a length for the column for use in DDL and CAST expressions. May be safely omitted if no CREATE TABLE will be issued. Certain databases may require a length for use in DDL, and will raise an exception when the CREATE TABLE DDL is issued if a VARCHAR with no length is included. Whether the value is interpreted as bytes or characters is database specific.

  • collation

    Optional, a column-level collation for use in DDL and CAST expressions. Renders using the COLLATE keyword supported by SQLite, MySQL, and PostgreSQL. E.g.:

    >>> from sqlalchemy import cast, select, String
    >>> print(select(cast('some string', String(collation='utf8'))))
    {printsql}SELECT CAST(:param_1 AS VARCHAR COLLATE utf8) AS anon_1
    

    Note

    In most cases, the Unicode or UnicodeText datatypes should be used for a _schema.Column that expects to store non-ascii data. These datatypes will ensure that the correct types are used on the database.

class Ltree[source]

Postgresql Ltree data type.

__init__(path_or_ltree)[source]
class MigrationState[source]

Migration service migration.

This data format is used by migration services to perform migrations. See an example below.

{
    "id": 0,
    "comments": "dev comments",
    "commands": [
        "ALTER TABLE my_table ADD COLUMN new_col DEFAULT NULL;",
        "ALTER TABLE my_table DROP COLUMN old_col;",
    ]
}
id: int

state id, sequential integer >= 0

comments: str

human readable comments

commands: list[str]

a list of sql commands performed inside a transaction block