class Sequence(IdentityOptions, DefaultGenerator):
Represents a named database sequence.
The .Sequence
object represents the name and configurational
parameters of a database sequence. It also represents
a construct that can be "executed" by a SQLAlchemy _engine.Engine
or _engine.Connection
,
rendering the appropriate "next value" function
for the target database and returning a result.
The .Sequence
is typically associated with a primary key column:
some_table = Table( 'some_table', metadata, Column('id', Integer, Sequence('some_table_seq'), primary_key=True) )
When CREATE TABLE is emitted for the above _schema.Table
, if the
target platform supports sequences, a CREATE SEQUENCE statement will
be emitted as well. For platforms that don't support sequences,
the .Sequence
construct is ignored.
Method | __init__ |
Construct a .Sequence object. |
Method | _not_a_column_expr |
Undocumented |
Method | _set_metadata |
Undocumented |
Method | _set_parent |
Associate with this SchemaEvent's parent object. |
Method | _set_table |
Undocumented |
Method | create |
Creates this sequence in the database. |
Method | drop |
Drops this sequence from the database. |
Method | next_value |
Return a .next_value function element which will render the appropriate increment function for this .Sequence within any SQL expression. |
Class Variable | __visit_name__ |
Undocumented |
Class Variable | is_sequence |
Undocumented |
Instance Variable | _key |
Undocumented |
Instance Variable | data_type |
Undocumented |
Instance Variable | metadata |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | optional |
Undocumented |
Instance Variable | schema |
Undocumented |
Property | bind |
Return the connectable associated with this default. |
Property | is_callable |
Undocumented |
Property | is_clause_element |
Undocumented |
Inherited from IdentityOptions
:
Instance Variable | cache |
Undocumented |
Instance Variable | cycle |
Undocumented |
Instance Variable | increment |
Undocumented |
Instance Variable | maxvalue |
Undocumented |
Instance Variable | minvalue |
Undocumented |
Instance Variable | nomaxvalue |
Undocumented |
Instance Variable | nominvalue |
Undocumented |
Instance Variable | order |
Undocumented |
Instance Variable | start |
Undocumented |
Inherited from DefaultGenerator
:
Method | _execute_on_connection |
Undocumented |
Method | execute |
Compile and execute this .Executable . |
Class Variable | is_server_default |
Undocumented |
Instance Variable | column |
Undocumented |
Instance Variable | for_update |
Undocumented |
Inherited from Executable
(via DefaultGenerator
):
Method | _add_context_option |
Add a context option to this statement. |
Method | _set_compile_options |
Assign the compile options to a new value. |
Method | _update_compile_options |
update the _compile_options with new keys. |
Method | execution_options |
Set non-SQL options for the statement which take effect during execution. |
Method | get_execution_options |
Get the non-SQL options which will take effect during execution. |
Method | options |
Apply options to this statement. |
Method | scalar |
Compile and execute this .Executable , returning the result's scalar representation. |
Class Variable | _bind |
Undocumented |
Class Variable | _executable_traverse_internals |
Undocumented |
Class Variable | _with_context_options |
Undocumented |
Class Variable | _with_options |
Undocumented |
Class Variable | is_delete |
Undocumented |
Class Variable | is_dml |
Undocumented |
Class Variable | is_insert |
Undocumented |
Class Variable | is_select |
Undocumented |
Class Variable | is_text |
Undocumented |
Class Variable | is_update |
Undocumented |
Class Variable | supports_execution |
Undocumented |
Instance Variable | _compile_options |
Undocumented |
Instance Variable | _execution_options |
Undocumented |
Property | _effective_plugin_target |
Undocumented |
Inherited from StatementRole
(via DefaultGenerator
, Executable
):
Class Variable | _propagate_attrs |
Undocumented |
Class Variable | _role_name |
Undocumented |
Inherited from SQLRole
(via DefaultGenerator
, Executable
, StatementRole
):
Class Variable | allows_lambda |
Undocumented |
Class Variable | uses_inspection |
Undocumented |
Inherited from Generative
(via DefaultGenerator
, Executable
):
Method | _generate |
Undocumented |
Inherited from SchemaItem
(via DefaultGenerator
):
Method | __repr__ |
Undocumented |
Method | _init_items |
Initialize the list of child items for this SchemaItem. |
Method | _schema_item_copy |
Undocumented |
Class Variable | _use_schema_map |
Undocumented |
Class Variable | create_drop_stringify_dialect |
Undocumented |
Property | info |
Info dictionary associated with the object, allowing user-defined data to be associated with this .SchemaItem . |
Inherited from SchemaEventTarget
(via DefaultGenerator
, SchemaItem
):
Method | _set_parent_with_dispatch |
Undocumented |
Inherited from Traversible
(via DefaultGenerator
, SchemaItem
):
Method | get_children |
Return immediate child .visitors.Traversible elements of this .visitors.Traversible . |
Method | __class_getitem__ |
Undocumented |
.Sequence
object.Parameters | |
name | the name of the sequence. |
start | the starting index of the sequence. This value is used when the CREATE SEQUENCE command is emitted to the database as the value of the "START WITH" clause. If None, the clause is omitted, which on most platforms indicates a starting value of 1. |
increment | the increment value of the sequence. This value is used when the CREATE SEQUENCE command is emitted to the database as the value of the "INCREMENT BY" clause. If None, the clause is omitted, which on most platforms indicates an increment of 1. |
minvalue | the minimum value of the sequence. This value is used when the CREATE SEQUENCE command is emitted to the database as the value of the "MINVALUE" clause. If None, the clause is omitted, which on most platforms indicates a minvalue of 1 and -2^63-1 for ascending and descending sequences, respectively.
New in version 1.0.7.
|
maxvalue | the maximum value of the sequence. This value is used when the CREATE SEQUENCE command is emitted to the database as the value of the "MAXVALUE" clause. If None, the clause is omitted, which on most platforms indicates a maxvalue of 2^63-1 and -1 for ascending and descending sequences, respectively.
New in version 1.0.7.
|
nominvalue | no minimum value of the sequence. This value is used when the CREATE SEQUENCE command is emitted to the database as the value of the "NO MINVALUE" clause. If None, the clause is omitted, which on most platforms indicates a minvalue of 1 and -2^63-1 for ascending and descending sequences, respectively.
New in version 1.0.7.
|
nomaxvalue | no maximum value of the sequence. This value is used when the CREATE SEQUENCE command is emitted to the database as the value of the "NO MAXVALUE" clause. If None, the clause is omitted, which on most platforms indicates a maxvalue of 2^63-1 and -1 for ascending and descending sequences, respectively.
New in version 1.0.7.
|
cycle | allows the sequence to wrap around when the maxvalue or minvalue has been reached by an ascending or descending sequence respectively. This value is used when the CREATE SEQUENCE command is emitted to the database as the "CYCLE" clause. If the limit is reached, the next number generated will be the minvalue or maxvalue, respectively. If cycle=False (the default) any calls to nextval after the sequence has reached its maximum value will return an error.
New in version 1.0.7.
|
schema | optional schema name for the sequence, if located
in a schema other than the default. The rules for selecting the
schema name when a _schema.MetaData
is also present are the same
as that of :paramref:`_schema.Table.schema`. |
cache | optional integer value; number of future values in the sequence which are calculated in advance. Renders the CACHE keyword understood by Oracle and PostgreSQL.
New in version 1.1.12.
|
order | optional boolean value; if True, renders the ORDER keyword, understood by Oracle, indicating the sequence is definitively ordered. May be necessary to provide deterministic ordering using Oracle RAC.
New in version 1.1.12.
|
data_type | The type to be returned by the sequence, for dialects that allow us to choose between INTEGER, BIGINT, etc. (e.g., mssql).
New in version 1.4.0.
|
optional | boolean value, when True, indicates that this
.Sequence object only needs to be explicitly generated
on backends that don't provide another way to generate primary
key identifiers. Currently, it essentially means, "don't create
this sequence on the PostgreSQL backend, where the SERIAL keyword
creates a sequence for us automatically". |
quote | boolean value, when True or False, explicitly forces quoting of the :paramref:`_schema.Sequence.name` on or off. When left at its default of None, normal quoting rules based on casing and reserved words take place. |
metadata | optional
The above behaviors can only occur if the See Also :ref:`sequence_metadata` - full discussion of the :paramref:`.Sequence.metadata` parameter. |
quote_schema | Set the quoting preferences for the schema name. |
for_update | Indicates this .Sequence , when associated
with a _schema.Column ,
should be invoked for UPDATE statements
on that column's table, rather than for INSERT statements, when
no value is otherwise present for that column in the statement. |
Creates this sequence in the database.
Note
the "bind" argument will be required in SQLAlchemy 2.0.
Drops this sequence from the database.
Note
the "bind" argument will be required in SQLAlchemy 2.0.
.next_value
function element
which will render the appropriate increment function
for this .Sequence
within any SQL expression.