sqlmeta.objects.sequence

Classes

Sequence(name[, schema, start_with, ...])

Represents a database sequence.

class sqlmeta.objects.sequence.Sequence(name: str, schema: str | None = None, start_with: int | None = None, increment_by: int | None = None, min_value: int | None = None, max_value: int | None = None, cycle: bool = False, cache: int | None = None, dialect: str | None = None, temp: bool = False)[source]

Represents a database sequence.

__init__(name: str, schema: str | None = None, start_with: int | None = None, increment_by: int | None = None, min_value: int | None = None, max_value: int | None = None, cycle: bool = False, cache: int | None = None, dialect: str | None = None, temp: bool = False)[source]

Initialize a sequence.

Parameters:
  • name – Sequence name

  • schema – Schema name

  • start_with – Starting value

  • increment_by – Increment value

  • min_value – Minimum value

  • max_value – Maximum value

  • cycle – Whether to cycle when reaching max_value

  • cache – Cache size

  • dialect – SQL dialect

  • temp – Whether sequence is TEMPORARY (PostgreSQL grammar-based)

property create_statement: str

Generate CREATE SEQUENCE statement.

The syntax varies by dialect.

Returns:

Dialect-specific CREATE SEQUENCE statement

property drop_statement: str

Generate DROP SEQUENCE statement.

Returns:

SQL DROP SEQUENCE statement for this sequence

classmethod from_dict(data: Dict[str, Any]) Sequence[source]

Create sequence from dictionary representation.

Parameters:

data – Dictionary with sequence attributes

Returns:

Sequence object

to_dict() Dict[str, Any][source]

Convert sequence to dictionary representation.

Returns:

Dictionary with sequence attributes