SQLAlchemy 2.1 Documentation
SQLAlchemy Core
- SQL Statements and Expressions API
- Schema Definition Language
- SQL Datatype Objects
- Engine and Connection Use
- Core API Basics
- Events
- Runtime Inspection API
- Core Exceptions
- Core Internals¶
BindTyping
Compiled
DBAPIConnection
DBAPICursor
DBAPICursor.arraysize
DBAPICursor.callproc()
DBAPICursor.close()
DBAPICursor.description
DBAPICursor.execute()
DBAPICursor.executemany()
DBAPICursor.fetchall()
DBAPICursor.fetchmany()
DBAPICursor.fetchone()
DBAPICursor.lastrowid
DBAPICursor.nextset()
DBAPICursor.rowcount
DBAPICursor.setinputsizes()
DBAPICursor.setoutputsize()
DBAPIType
DDLCompiler
DDLCompiler.__init__()
DDLCompiler.cache_key
DDLCompiler.compile_state
DDLCompiler.construct_params()
DDLCompiler.define_constraint_remote_table()
DDLCompiler.dml_compile_state
DDLCompiler.execution_options
DDLCompiler.params
DDLCompiler.sql_compiler
DDLCompiler.state
DDLCompiler.statement
DDLCompiler.string
DefaultDialect
DefaultDialect.bind_typing
DefaultDialect.colspecs
DefaultDialect.connect()
DefaultDialect.construct_arguments
DefaultDialect.create_connect_args()
DefaultDialect.create_xid()
DefaultDialect.cte_follows_insert
DefaultDialect.dbapi
DefaultDialect.dbapi_exception_translation_map
DefaultDialect.ddl_compiler
DefaultDialect.default_isolation_level
DefaultDialect.default_metavalue_token
DefaultDialect.default_schema_name
DefaultDialect.default_sequence_base
DefaultDialect.delete_executemany_returning
DefaultDialect.delete_returning
DefaultDialect.delete_returning_multifrom
DefaultDialect.denormalize_name()
DefaultDialect.div_is_floordiv
DefaultDialect.do_begin()
DefaultDialect.do_begin_twophase()
DefaultDialect.do_close()
DefaultDialect.do_commit()
DefaultDialect.do_commit_twophase()
DefaultDialect.do_execute()
DefaultDialect.do_execute_no_params()
DefaultDialect.do_executemany()
DefaultDialect.do_ping()
DefaultDialect.do_prepare_twophase()
DefaultDialect.do_recover_twophase()
DefaultDialect.do_release_savepoint()
DefaultDialect.do_rollback()
DefaultDialect.do_rollback_to_savepoint()
DefaultDialect.do_rollback_twophase()
DefaultDialect.do_savepoint()
DefaultDialect.do_set_input_sizes()
DefaultDialect.do_terminate()
DefaultDialect.driver
DefaultDialect.engine_config_types
DefaultDialect.engine_created()
DefaultDialect.exclude_set_input_sizes
DefaultDialect.execute_sequence_format
DefaultDialect.execution_ctx_cls
DefaultDialect.favor_returning_over_lastrowid
DefaultDialect.full_returning
DefaultDialect.get_async_dialect_cls()
DefaultDialect.get_check_constraints()
DefaultDialect.get_columns()
DefaultDialect.get_default_isolation_level()
DefaultDialect.get_dialect_cls()
DefaultDialect.get_dialect_pool_class()
DefaultDialect.get_driver_connection()
DefaultDialect.get_foreign_keys()
DefaultDialect.get_indexes()
DefaultDialect.get_isolation_level()
DefaultDialect.get_isolation_level_values()
DefaultDialect.get_materialized_view_names()
DefaultDialect.get_multi_check_constraints()
DefaultDialect.get_multi_columns()
DefaultDialect.get_multi_foreign_keys()
DefaultDialect.get_multi_indexes()
DefaultDialect.get_multi_pk_constraint()
DefaultDialect.get_multi_table_comment()
DefaultDialect.get_multi_table_options()
DefaultDialect.get_multi_unique_constraints()
DefaultDialect.get_pk_constraint()
DefaultDialect.get_schema_names()
DefaultDialect.get_sequence_names()
DefaultDialect.get_table_comment()
DefaultDialect.get_table_names()
DefaultDialect.get_table_options()
DefaultDialect.get_temp_table_names()
DefaultDialect.get_temp_view_names()
DefaultDialect.get_unique_constraints()
DefaultDialect.get_view_definition()
DefaultDialect.get_view_names()
DefaultDialect.has_index()
DefaultDialect.has_schema()
DefaultDialect.has_sequence()
DefaultDialect.has_table()
DefaultDialect.has_terminate
DefaultDialect.identifier_preparer
DefaultDialect.import_dbapi()
DefaultDialect.include_set_input_sizes
DefaultDialect.initialize()
DefaultDialect.inline_comments
DefaultDialect.insert_executemany_returning
DefaultDialect.insert_executemany_returning_sort_by_parameter_order
DefaultDialect.insert_returning
DefaultDialect.insertmanyvalues_implicit_sentinel
DefaultDialect.insertmanyvalues_max_parameters
DefaultDialect.insertmanyvalues_page_size
DefaultDialect.is_async
DefaultDialect.is_disconnect()
DefaultDialect.label_length
DefaultDialect.load_provisioning()
DefaultDialect.loaded_dbapi
DefaultDialect.max_identifier_length
DefaultDialect.name
DefaultDialect.normalize_name()
DefaultDialect.on_connect()
DefaultDialect.on_connect_url()
DefaultDialect.paramstyle
DefaultDialect.positional
DefaultDialect.preexecute_autoincrement_sequences
DefaultDialect.preparer
DefaultDialect.reflection_options
DefaultDialect.reset_isolation_level()
DefaultDialect.returns_native_bytes
DefaultDialect.sequences_optional
DefaultDialect.server_side_cursors
DefaultDialect.server_version_info
DefaultDialect.set_connection_execution_options()
DefaultDialect.set_engine_execution_options()
DefaultDialect.set_isolation_level()
DefaultDialect.statement_compiler
DefaultDialect.supports_alter
DefaultDialect.supports_comments
DefaultDialect.supports_constraint_comments
DefaultDialect.supports_default_metavalue
DefaultDialect.supports_default_values
DefaultDialect.supports_empty_insert
DefaultDialect.supports_identity_columns
DefaultDialect.supports_multivalues_insert
DefaultDialect.supports_native_boolean
DefaultDialect.supports_native_decimal
DefaultDialect.supports_native_enum
DefaultDialect.supports_native_uuid
DefaultDialect.supports_sane_multi_rowcount
DefaultDialect.supports_sane_rowcount
DefaultDialect.supports_sane_rowcount_returning
DefaultDialect.supports_sequences
DefaultDialect.supports_server_side_cursors
DefaultDialect.supports_simple_order_by_label
DefaultDialect.supports_statement_cache
DefaultDialect.tuple_in_values
DefaultDialect.type_compiler
DefaultDialect.type_compiler_cls
DefaultDialect.type_compiler_instance
DefaultDialect.type_descriptor()
DefaultDialect.update_executemany_returning
DefaultDialect.update_returning
DefaultDialect.update_returning_multifrom
DefaultDialect.use_insertmanyvalues
DefaultDialect.use_insertmanyvalues_wo_returning
Dialect
Dialect.bind_typing
Dialect.colspecs
Dialect.connect()
Dialect.construct_arguments
Dialect.create_connect_args()
Dialect.create_xid()
Dialect.cte_follows_insert
Dialect.dbapi
Dialect.dbapi_exception_translation_map
Dialect.ddl_compiler
Dialect.default_isolation_level
Dialect.default_metavalue_token
Dialect.default_schema_name
Dialect.default_sequence_base
Dialect.delete_executemany_returning
Dialect.delete_returning
Dialect.delete_returning_multifrom
Dialect.denormalize_name()
Dialect.div_is_floordiv
Dialect.do_begin()
Dialect.do_begin_twophase()
Dialect.do_close()
Dialect.do_commit()
Dialect.do_commit_twophase()
Dialect.do_execute()
Dialect.do_execute_no_params()
Dialect.do_executemany()
Dialect.do_ping()
Dialect.do_prepare_twophase()
Dialect.do_recover_twophase()
Dialect.do_release_savepoint()
Dialect.do_rollback()
Dialect.do_rollback_to_savepoint()
Dialect.do_rollback_twophase()
Dialect.do_savepoint()
Dialect.do_set_input_sizes()
Dialect.do_terminate()
Dialect.driver
Dialect.engine_config_types
Dialect.engine_created()
Dialect.exclude_set_input_sizes
Dialect.execute_sequence_format
Dialect.execution_ctx_cls
Dialect.favor_returning_over_lastrowid
Dialect.get_async_dialect_cls()
Dialect.get_check_constraints()
Dialect.get_columns()
Dialect.get_default_isolation_level()
Dialect.get_dialect_cls()
Dialect.get_dialect_pool_class()
Dialect.get_driver_connection()
Dialect.get_foreign_keys()
Dialect.get_indexes()
Dialect.get_isolation_level()
Dialect.get_isolation_level_values()
Dialect.get_materialized_view_names()
Dialect.get_multi_check_constraints()
Dialect.get_multi_columns()
Dialect.get_multi_foreign_keys()
Dialect.get_multi_indexes()
Dialect.get_multi_pk_constraint()
Dialect.get_multi_table_comment()
Dialect.get_multi_table_options()
Dialect.get_multi_unique_constraints()
Dialect.get_pk_constraint()
Dialect.get_schema_names()
Dialect.get_sequence_names()
Dialect.get_table_comment()
Dialect.get_table_names()
Dialect.get_table_options()
Dialect.get_temp_table_names()
Dialect.get_temp_view_names()
Dialect.get_unique_constraints()
Dialect.get_view_definition()
Dialect.get_view_names()
Dialect.has_index()
Dialect.has_schema()
Dialect.has_sequence()
Dialect.has_table()
Dialect.has_terminate
Dialect.identifier_preparer
Dialect.import_dbapi()
Dialect.include_set_input_sizes
Dialect.initialize()
Dialect.inline_comments
Dialect.insert_executemany_returning
Dialect.insert_executemany_returning_sort_by_parameter_order
Dialect.insert_returning
Dialect.insertmanyvalues_implicit_sentinel
Dialect.insertmanyvalues_max_parameters
Dialect.insertmanyvalues_page_size
Dialect.is_async
Dialect.is_disconnect()
Dialect.label_length
Dialect.load_provisioning()
Dialect.loaded_dbapi
Dialect.max_identifier_length
Dialect.name
Dialect.normalize_name()
Dialect.on_connect()
Dialect.on_connect_url()
Dialect.paramstyle
Dialect.positional
Dialect.preexecute_autoincrement_sequences
Dialect.preparer
Dialect.reflection_options
Dialect.reset_isolation_level()
Dialect.returns_native_bytes
Dialect.sequences_optional
Dialect.server_side_cursors
Dialect.server_version_info
Dialect.set_connection_execution_options()
Dialect.set_engine_execution_options()
Dialect.set_isolation_level()
Dialect.statement_compiler
Dialect.supports_alter
Dialect.supports_comments
Dialect.supports_constraint_comments
Dialect.supports_default_metavalue
Dialect.supports_default_values
Dialect.supports_empty_insert
Dialect.supports_identity_columns
Dialect.supports_multivalues_insert
Dialect.supports_native_boolean
Dialect.supports_native_decimal
Dialect.supports_native_enum
Dialect.supports_native_uuid
Dialect.supports_sane_multi_rowcount
Dialect.supports_sane_rowcount
Dialect.supports_sequences
Dialect.supports_server_side_cursors
Dialect.supports_simple_order_by_label
Dialect.supports_statement_cache
Dialect.tuple_in_values
Dialect.type_compiler
Dialect.type_compiler_cls
Dialect.type_compiler_instance
Dialect.type_descriptor()
Dialect.update_executemany_returning
Dialect.update_returning
Dialect.update_returning_multifrom
Dialect.use_insertmanyvalues
Dialect.use_insertmanyvalues_wo_returning
DefaultExecutionContext
DefaultExecutionContext.compiled
DefaultExecutionContext.connection
DefaultExecutionContext.create_cursor()
DefaultExecutionContext.current_parameters
DefaultExecutionContext.cursor
DefaultExecutionContext.dialect
DefaultExecutionContext.engine
DefaultExecutionContext.execute_style
DefaultExecutionContext.executemany
DefaultExecutionContext.execution_options
DefaultExecutionContext.fetchall_for_returning()
DefaultExecutionContext.get_current_parameters()
DefaultExecutionContext.get_lastrowid()
DefaultExecutionContext.get_out_parameter_values()
DefaultExecutionContext.get_result_processor()
DefaultExecutionContext.handle_dbapi_exception()
DefaultExecutionContext.invoked_statement
DefaultExecutionContext.isinsert
DefaultExecutionContext.isupdate
DefaultExecutionContext.lastrow_has_defaults()
DefaultExecutionContext.no_parameters
DefaultExecutionContext.parameters
DefaultExecutionContext.post_exec()
DefaultExecutionContext.postfetch_cols
DefaultExecutionContext.pre_exec()
DefaultExecutionContext.prefetch_cols
DefaultExecutionContext.root_connection
ExecutionContext
ExecutionContext.compiled
ExecutionContext.connection
ExecutionContext.create_cursor()
ExecutionContext.cursor
ExecutionContext.dialect
ExecutionContext.engine
ExecutionContext.execute_style
ExecutionContext.executemany
ExecutionContext.execution_options
ExecutionContext.fetchall_for_returning()
ExecutionContext.fire_sequence()
ExecutionContext.get_out_parameter_values()
ExecutionContext.get_rowcount()
ExecutionContext.handle_dbapi_exception()
ExecutionContext.invoked_statement
ExecutionContext.isinsert
ExecutionContext.isupdate
ExecutionContext.lastrow_has_defaults()
ExecutionContext.no_parameters
ExecutionContext.parameters
ExecutionContext.post_exec()
ExecutionContext.postfetch_cols
ExecutionContext.pre_exec()
ExecutionContext.prefetch_cols
ExecutionContext.root_connection
ExecutionContext.statement
ExpandedState
GenericTypeCompiler
Identified
IdentifierPreparer
IdentifierPreparer.__init__()
IdentifierPreparer.format_column()
IdentifierPreparer.format_label_name()
IdentifierPreparer.format_schema()
IdentifierPreparer.format_table()
IdentifierPreparer.format_table_seq()
IdentifierPreparer.quote()
IdentifierPreparer.quote_identifier()
IdentifierPreparer.quote_schema()
IdentifierPreparer.schema_for_object
IdentifierPreparer.unformat_identifiers()
IdentifierPreparer.validate_sql_phrase()
SQLCompiler
SQLCompiler.__init__()
SQLCompiler.ansi_bind_rules
SQLCompiler.bind_names
SQLCompiler.bindname_escape_characters
SQLCompiler.binds
SQLCompiler.bindtemplate
SQLCompiler.compilation_bindtemplate
SQLCompiler.construct_expanded_state()
SQLCompiler.construct_params()
SQLCompiler.current_executable
SQLCompiler.default_from()
SQLCompiler.delete_extra_from_clause()
SQLCompiler.effective_returning
SQLCompiler.escaped_bind_names
SQLCompiler.get_select_precolumns()
SQLCompiler.group_by_clause()
SQLCompiler.has_out_parameters
SQLCompiler.implicit_returning
SQLCompiler.insert_prefetch
SQLCompiler.insert_single_values_expr
SQLCompiler.isupdate
SQLCompiler.literal_execute_params
SQLCompiler.order_by_clause()
SQLCompiler.params
SQLCompiler.positiontup
SQLCompiler.post_compile_params
SQLCompiler.postfetch
SQLCompiler.postfetch_lastrowid
SQLCompiler.render_literal_value()
SQLCompiler.render_table_with_column_in_update_from
SQLCompiler.returning
SQLCompiler.returning_precedes_values
SQLCompiler.sql_compiler
SQLCompiler.stack
SQLCompiler.translate_select_structure
SQLCompiler.update_from_clause()
SQLCompiler.update_limit_clause()
SQLCompiler.update_prefetch
SQLCompiler.update_tables_clause()
SQLCompiler.visit_override_binds()
StrSQLCompiler
AdaptedConnection
Project Versions
- Previous: Core Exceptions
- Next: Dialects
- Up: Home
- On this page:
- Core Internals
BindTyping
Compiled
DBAPIConnection
DBAPICursor
DBAPICursor.arraysize
DBAPICursor.callproc()
DBAPICursor.close()
DBAPICursor.description
DBAPICursor.execute()
DBAPICursor.executemany()
DBAPICursor.fetchall()
DBAPICursor.fetchmany()
DBAPICursor.fetchone()
DBAPICursor.lastrowid
DBAPICursor.nextset()
DBAPICursor.rowcount
DBAPICursor.setinputsizes()
DBAPICursor.setoutputsize()
DBAPIType
DDLCompiler
DDLCompiler.__init__()
DDLCompiler.cache_key
DDLCompiler.compile_state
DDLCompiler.construct_params()
DDLCompiler.define_constraint_remote_table()
DDLCompiler.dml_compile_state
DDLCompiler.execution_options
DDLCompiler.params
DDLCompiler.sql_compiler
DDLCompiler.state
DDLCompiler.statement
DDLCompiler.string
DefaultDialect
DefaultDialect.bind_typing
DefaultDialect.colspecs
DefaultDialect.connect()
DefaultDialect.construct_arguments
DefaultDialect.create_connect_args()
DefaultDialect.create_xid()
DefaultDialect.cte_follows_insert
DefaultDialect.dbapi
DefaultDialect.dbapi_exception_translation_map
DefaultDialect.ddl_compiler
DefaultDialect.default_isolation_level
DefaultDialect.default_metavalue_token
DefaultDialect.default_schema_name
DefaultDialect.default_sequence_base
DefaultDialect.delete_executemany_returning
DefaultDialect.delete_returning
DefaultDialect.delete_returning_multifrom
DefaultDialect.denormalize_name()
DefaultDialect.div_is_floordiv
DefaultDialect.do_begin()
DefaultDialect.do_begin_twophase()
DefaultDialect.do_close()
DefaultDialect.do_commit()
DefaultDialect.do_commit_twophase()
DefaultDialect.do_execute()
DefaultDialect.do_execute_no_params()
DefaultDialect.do_executemany()
DefaultDialect.do_ping()
DefaultDialect.do_prepare_twophase()
DefaultDialect.do_recover_twophase()
DefaultDialect.do_release_savepoint()
DefaultDialect.do_rollback()
DefaultDialect.do_rollback_to_savepoint()
DefaultDialect.do_rollback_twophase()
DefaultDialect.do_savepoint()
DefaultDialect.do_set_input_sizes()
DefaultDialect.do_terminate()
DefaultDialect.driver
DefaultDialect.engine_config_types
DefaultDialect.engine_created()
DefaultDialect.exclude_set_input_sizes
DefaultDialect.execute_sequence_format
DefaultDialect.execution_ctx_cls
DefaultDialect.favor_returning_over_lastrowid
DefaultDialect.full_returning
DefaultDialect.get_async_dialect_cls()
DefaultDialect.get_check_constraints()
DefaultDialect.get_columns()
DefaultDialect.get_default_isolation_level()
DefaultDialect.get_dialect_cls()
DefaultDialect.get_dialect_pool_class()
DefaultDialect.get_driver_connection()
DefaultDialect.get_foreign_keys()
DefaultDialect.get_indexes()
DefaultDialect.get_isolation_level()
DefaultDialect.get_isolation_level_values()
DefaultDialect.get_materialized_view_names()
DefaultDialect.get_multi_check_constraints()
DefaultDialect.get_multi_columns()
DefaultDialect.get_multi_foreign_keys()
DefaultDialect.get_multi_indexes()
DefaultDialect.get_multi_pk_constraint()
DefaultDialect.get_multi_table_comment()
DefaultDialect.get_multi_table_options()
DefaultDialect.get_multi_unique_constraints()
DefaultDialect.get_pk_constraint()
DefaultDialect.get_schema_names()
DefaultDialect.get_sequence_names()
DefaultDialect.get_table_comment()
DefaultDialect.get_table_names()
DefaultDialect.get_table_options()
DefaultDialect.get_temp_table_names()
DefaultDialect.get_temp_view_names()
DefaultDialect.get_unique_constraints()
DefaultDialect.get_view_definition()
DefaultDialect.get_view_names()
DefaultDialect.has_index()
DefaultDialect.has_schema()
DefaultDialect.has_sequence()
DefaultDialect.has_table()
DefaultDialect.has_terminate
DefaultDialect.identifier_preparer
DefaultDialect.import_dbapi()
DefaultDialect.include_set_input_sizes
DefaultDialect.initialize()
DefaultDialect.inline_comments
DefaultDialect.insert_executemany_returning
DefaultDialect.insert_executemany_returning_sort_by_parameter_order
DefaultDialect.insert_returning
DefaultDialect.insertmanyvalues_implicit_sentinel
DefaultDialect.insertmanyvalues_max_parameters
DefaultDialect.insertmanyvalues_page_size
DefaultDialect.is_async
DefaultDialect.is_disconnect()
DefaultDialect.label_length
DefaultDialect.load_provisioning()
DefaultDialect.loaded_dbapi
DefaultDialect.max_identifier_length
DefaultDialect.name
DefaultDialect.normalize_name()
DefaultDialect.on_connect()
DefaultDialect.on_connect_url()
DefaultDialect.paramstyle
DefaultDialect.positional
DefaultDialect.preexecute_autoincrement_sequences
DefaultDialect.preparer
DefaultDialect.reflection_options
DefaultDialect.reset_isolation_level()
DefaultDialect.returns_native_bytes
DefaultDialect.sequences_optional
DefaultDialect.server_side_cursors
DefaultDialect.server_version_info
DefaultDialect.set_connection_execution_options()
DefaultDialect.set_engine_execution_options()
DefaultDialect.set_isolation_level()
DefaultDialect.statement_compiler
DefaultDialect.supports_alter
DefaultDialect.supports_comments
DefaultDialect.supports_constraint_comments
DefaultDialect.supports_default_metavalue
DefaultDialect.supports_default_values
DefaultDialect.supports_empty_insert
DefaultDialect.supports_identity_columns
DefaultDialect.supports_multivalues_insert
DefaultDialect.supports_native_boolean
DefaultDialect.supports_native_decimal
DefaultDialect.supports_native_enum
DefaultDialect.supports_native_uuid
DefaultDialect.supports_sane_multi_rowcount
DefaultDialect.supports_sane_rowcount
DefaultDialect.supports_sane_rowcount_returning
DefaultDialect.supports_sequences
DefaultDialect.supports_server_side_cursors
DefaultDialect.supports_simple_order_by_label
DefaultDialect.supports_statement_cache
DefaultDialect.tuple_in_values
DefaultDialect.type_compiler
DefaultDialect.type_compiler_cls
DefaultDialect.type_compiler_instance
DefaultDialect.type_descriptor()
DefaultDialect.update_executemany_returning
DefaultDialect.update_returning
DefaultDialect.update_returning_multifrom
DefaultDialect.use_insertmanyvalues
DefaultDialect.use_insertmanyvalues_wo_returning
Dialect
Dialect.bind_typing
Dialect.colspecs
Dialect.connect()
Dialect.construct_arguments
Dialect.create_connect_args()
Dialect.create_xid()
Dialect.cte_follows_insert
Dialect.dbapi
Dialect.dbapi_exception_translation_map
Dialect.ddl_compiler
Dialect.default_isolation_level
Dialect.default_metavalue_token
Dialect.default_schema_name
Dialect.default_sequence_base
Dialect.delete_executemany_returning
Dialect.delete_returning
Dialect.delete_returning_multifrom
Dialect.denormalize_name()
Dialect.div_is_floordiv
Dialect.do_begin()
Dialect.do_begin_twophase()
Dialect.do_close()
Dialect.do_commit()
Dialect.do_commit_twophase()
Dialect.do_execute()
Dialect.do_execute_no_params()
Dialect.do_executemany()
Dialect.do_ping()
Dialect.do_prepare_twophase()
Dialect.do_recover_twophase()
Dialect.do_release_savepoint()
Dialect.do_rollback()
Dialect.do_rollback_to_savepoint()
Dialect.do_rollback_twophase()
Dialect.do_savepoint()
Dialect.do_set_input_sizes()
Dialect.do_terminate()
Dialect.driver
Dialect.engine_config_types
Dialect.engine_created()
Dialect.exclude_set_input_sizes
Dialect.execute_sequence_format
Dialect.execution_ctx_cls
Dialect.favor_returning_over_lastrowid
Dialect.get_async_dialect_cls()
Dialect.get_check_constraints()
Dialect.get_columns()
Dialect.get_default_isolation_level()
Dialect.get_dialect_cls()
Dialect.get_dialect_pool_class()
Dialect.get_driver_connection()
Dialect.get_foreign_keys()
Dialect.get_indexes()
Dialect.get_isolation_level()
Dialect.get_isolation_level_values()
Dialect.get_materialized_view_names()
Dialect.get_multi_check_constraints()
Dialect.get_multi_columns()
Dialect.get_multi_foreign_keys()
Dialect.get_multi_indexes()
Dialect.get_multi_pk_constraint()
Dialect.get_multi_table_comment()
Dialect.get_multi_table_options()
Dialect.get_multi_unique_constraints()
Dialect.get_pk_constraint()
Dialect.get_schema_names()
Dialect.get_sequence_names()
Dialect.get_table_comment()
Dialect.get_table_names()
Dialect.get_table_options()
Dialect.get_temp_table_names()
Dialect.get_temp_view_names()
Dialect.get_unique_constraints()
Dialect.get_view_definition()
Dialect.get_view_names()
Dialect.has_index()
Dialect.has_schema()
Dialect.has_sequence()
Dialect.has_table()
Dialect.has_terminate
Dialect.identifier_preparer
Dialect.import_dbapi()
Dialect.include_set_input_sizes
Dialect.initialize()
Dialect.inline_comments
Dialect.insert_executemany_returning
Dialect.insert_executemany_returning_sort_by_parameter_order
Dialect.insert_returning
Dialect.insertmanyvalues_implicit_sentinel
Dialect.insertmanyvalues_max_parameters
Dialect.insertmanyvalues_page_size
Dialect.is_async
Dialect.is_disconnect()
Dialect.label_length
Dialect.load_provisioning()
Dialect.loaded_dbapi
Dialect.max_identifier_length
Dialect.name
Dialect.normalize_name()
Dialect.on_connect()
Dialect.on_connect_url()
Dialect.paramstyle
Dialect.positional
Dialect.preexecute_autoincrement_sequences
Dialect.preparer
Dialect.reflection_options
Dialect.reset_isolation_level()
Dialect.returns_native_bytes
Dialect.sequences_optional
Dialect.server_side_cursors
Dialect.server_version_info
Dialect.set_connection_execution_options()
Dialect.set_engine_execution_options()
Dialect.set_isolation_level()
Dialect.statement_compiler
Dialect.supports_alter
Dialect.supports_comments
Dialect.supports_constraint_comments
Dialect.supports_default_metavalue
Dialect.supports_default_values
Dialect.supports_empty_insert
Dialect.supports_identity_columns
Dialect.supports_multivalues_insert
Dialect.supports_native_boolean
Dialect.supports_native_decimal
Dialect.supports_native_enum
Dialect.supports_native_uuid
Dialect.supports_sane_multi_rowcount
Dialect.supports_sane_rowcount
Dialect.supports_sequences
Dialect.supports_server_side_cursors
Dialect.supports_simple_order_by_label
Dialect.supports_statement_cache
Dialect.tuple_in_values
Dialect.type_compiler
Dialect.type_compiler_cls
Dialect.type_compiler_instance
Dialect.type_descriptor()
Dialect.update_executemany_returning
Dialect.update_returning
Dialect.update_returning_multifrom
Dialect.use_insertmanyvalues
Dialect.use_insertmanyvalues_wo_returning
DefaultExecutionContext
DefaultExecutionContext.compiled
DefaultExecutionContext.connection
DefaultExecutionContext.create_cursor()
DefaultExecutionContext.current_parameters
DefaultExecutionContext.cursor
DefaultExecutionContext.dialect
DefaultExecutionContext.engine
DefaultExecutionContext.execute_style
DefaultExecutionContext.executemany
DefaultExecutionContext.execution_options
DefaultExecutionContext.fetchall_for_returning()
DefaultExecutionContext.get_current_parameters()
DefaultExecutionContext.get_lastrowid()
DefaultExecutionContext.get_out_parameter_values()
DefaultExecutionContext.get_result_processor()
DefaultExecutionContext.handle_dbapi_exception()
DefaultExecutionContext.invoked_statement
DefaultExecutionContext.isinsert
DefaultExecutionContext.isupdate
DefaultExecutionContext.lastrow_has_defaults()
DefaultExecutionContext.no_parameters
DefaultExecutionContext.parameters
DefaultExecutionContext.post_exec()
DefaultExecutionContext.postfetch_cols
DefaultExecutionContext.pre_exec()
DefaultExecutionContext.prefetch_cols
DefaultExecutionContext.root_connection
ExecutionContext
ExecutionContext.compiled
ExecutionContext.connection
ExecutionContext.create_cursor()
ExecutionContext.cursor
ExecutionContext.dialect
ExecutionContext.engine
ExecutionContext.execute_style
ExecutionContext.executemany
ExecutionContext.execution_options
ExecutionContext.fetchall_for_returning()
ExecutionContext.fire_sequence()
ExecutionContext.get_out_parameter_values()
ExecutionContext.get_rowcount()
ExecutionContext.handle_dbapi_exception()
ExecutionContext.invoked_statement
ExecutionContext.isinsert
ExecutionContext.isupdate
ExecutionContext.lastrow_has_defaults()
ExecutionContext.no_parameters
ExecutionContext.parameters
ExecutionContext.post_exec()
ExecutionContext.postfetch_cols
ExecutionContext.pre_exec()
ExecutionContext.prefetch_cols
ExecutionContext.root_connection
ExecutionContext.statement
ExpandedState
GenericTypeCompiler
Identified
IdentifierPreparer
IdentifierPreparer.__init__()
IdentifierPreparer.format_column()
IdentifierPreparer.format_label_name()
IdentifierPreparer.format_schema()
IdentifierPreparer.format_table()
IdentifierPreparer.format_table_seq()
IdentifierPreparer.quote()
IdentifierPreparer.quote_identifier()
IdentifierPreparer.quote_schema()
IdentifierPreparer.schema_for_object
IdentifierPreparer.unformat_identifiers()
IdentifierPreparer.validate_sql_phrase()
SQLCompiler
SQLCompiler.__init__()
SQLCompiler.ansi_bind_rules
SQLCompiler.bind_names
SQLCompiler.bindname_escape_characters
SQLCompiler.binds
SQLCompiler.bindtemplate
SQLCompiler.compilation_bindtemplate
SQLCompiler.construct_expanded_state()
SQLCompiler.construct_params()
SQLCompiler.current_executable
SQLCompiler.default_from()
SQLCompiler.delete_extra_from_clause()
SQLCompiler.effective_returning
SQLCompiler.escaped_bind_names
SQLCompiler.get_select_precolumns()
SQLCompiler.group_by_clause()
SQLCompiler.has_out_parameters
SQLCompiler.implicit_returning
SQLCompiler.insert_prefetch
SQLCompiler.insert_single_values_expr
SQLCompiler.isupdate
SQLCompiler.literal_execute_params
SQLCompiler.order_by_clause()
SQLCompiler.params
SQLCompiler.positiontup
SQLCompiler.post_compile_params
SQLCompiler.postfetch
SQLCompiler.postfetch_lastrowid
SQLCompiler.render_literal_value()
SQLCompiler.render_table_with_column_in_update_from
SQLCompiler.returning
SQLCompiler.returning_precedes_values
SQLCompiler.sql_compiler
SQLCompiler.stack
SQLCompiler.translate_select_structure
SQLCompiler.update_from_clause()
SQLCompiler.update_limit_clause()
SQLCompiler.update_prefetch
SQLCompiler.update_tables_clause()
SQLCompiler.visit_override_binds()
StrSQLCompiler
AdaptedConnection
Core Internals¶
Some key internal constructs are listed here.
Object Name | Description |
---|---|
Interface of an adapted connection object to support the DBAPI protocol. |
|
Define different methods of passing typing information for bound parameters in a statement to the database driver. |
|
Represent a compiled SQL or DDL expression. |
|
protocol representing a PEP 249 database connection. |
|
protocol representing a PEP 249 database cursor. |
|
protocol representing a PEP 249 database type. |
|
Default implementation of Dialect |
|
Define the behavior of a specific database and DB-API combination. |
|
A messenger object for a Dialect that corresponds to a single execution. |
|
represents state to use when producing “expanded” and “post compile” bound parameters for a statement. |
|
Handle quoting and case-folding of identifiers based on options. |
|
Default implementation of |
|
A |
- class sqlalchemy.engine.BindTyping¶
Define different methods of passing typing information for bound parameters in a statement to the database driver.
New in version 2.0.
Members
Class signature
class
sqlalchemy.engine.BindTyping
(enum.Enum
)-
attribute
sqlalchemy.engine.BindTyping.
NONE = 1¶ No steps are taken to pass typing information to the database driver.
This is the default behavior for databases such as SQLite, MySQL / MariaDB, SQL Server.
-
attribute
sqlalchemy.engine.BindTyping.
RENDER_CASTS = 3¶ Render casts or other directives in the SQL string.
This method is used for all PostgreSQL dialects, including asyncpg, pg8000, psycopg, psycopg2. Dialects which implement this can choose which kinds of datatypes are explicitly cast in SQL statements and which aren’t.
When RENDER_CASTS is used, the compiler will invoke the
SQLCompiler.render_bind_cast()
method for the rendered string representation of eachBindParameter
object whose dialect-level type sets theTypeEngine.render_bind_cast
attribute.The
SQLCompiler.render_bind_cast()
is also used to render casts for one form of “insertmanyvalues” query, when bothInsertmanyvaluesSentinelOpts.USE_INSERT_FROM_SELECT
andInsertmanyvaluesSentinelOpts.RENDER_SELECT_COL_CASTS
are set, where the casts are applied to the intermediary columns e.g. “INSERT INTO t (a, b, c) SELECT p0::TYP, p1::TYP, p2::TYP ” “FROM (VALUES (?, ?), (?, ?), …)”.New in version 2.0.10: -
SQLCompiler.render_bind_cast()
is now used within some elements of the “insertmanyvalues” implementation.
-
attribute
sqlalchemy.engine.BindTyping.
SETINPUTSIZES = 2¶ Use the pep-249 setinputsizes method.
This is only implemented for DBAPIs that support this method and for which the SQLAlchemy dialect has the appropriate infrastructure for that dialect set up. Current dialects include cx_Oracle as well as optional support for SQL Server using pyodbc.
When using setinputsizes, dialects also have a means of only using the method for certain datatypes using include/exclude lists.
When SETINPUTSIZES is used, the
Dialect.do_set_input_sizes()
method is called for each statement executed which has bound parameters.
-
attribute
- class sqlalchemy.engine.Compiled¶
Represent a compiled SQL or DDL expression.
Members
__init__(), cache_key, compile_state, construct_params(), dml_compile_state, execution_options, params, sql_compiler, state, statement, string
The
__str__
method of theCompiled
object should produce the actual text of the statement.Compiled
objects are specific to their underlying database dialect, and also may or may not be specific to the columns referenced within a particular set of bind parameters. In no case should theCompiled
object be dependent on the actual values of those bind parameters, even though it may reference those values as defaults.-
method
sqlalchemy.engine.Compiled.
__init__(dialect: Dialect, statement: ClauseElement | None, schema_translate_map: SchemaTranslateMapType | None = None, render_schema_translate: bool = False, compile_kwargs: Mapping[str, Any] = {})¶ Construct a new
Compiled
object.- Parameters:
statement¶ –
ClauseElement
to be compiled.schema_translate_map¶ –
dictionary of schema names to be translated when forming the resultant SQL
See also
compile_kwargs¶ – additional kwargs that will be passed to the initial call to
Compiled.process()
.
-
attribute
sqlalchemy.engine.Compiled.
cache_key: CacheKey | None = None¶ The
CacheKey
that was generated ahead of creating thisCompiled
object.This is used for routines that need access to the original
CacheKey
instance generated when theCompiled
instance was first cached, typically in order to reconcile the original list ofBindParameter
objects with a per-statement list that’s generated on each call.
-
attribute
sqlalchemy.engine.Compiled.
compile_state: CompileState | None = None¶ Optional
CompileState
object that maintains additional state used by the compiler.Major executable objects such as
Insert
,Update
,Delete
,Select
will generate this state when compiled in order to calculate additional information about the object. For the top level object that is to be executed, the state can be stored here where it can also have applicability towards result set processing.New in version 1.4.
-
method
sqlalchemy.engine.Compiled.
construct_params(params: _CoreSingleExecuteParams | None = None, extracted_parameters: Sequence[BindParameter[Any]] | None = None, escape_names: bool = True) → _MutableCoreSingleExecuteParams | None¶ Return the bind params for this compiled object.
- Parameters:
params¶ – a dict of string/object pairs whose values will override bind values compiled in to the statement.
-
attribute
sqlalchemy.engine.Compiled.
dml_compile_state: CompileState | None = None¶ Optional
CompileState
assigned at the same point that .isinsert, .isupdate, or .isdelete is assigned.This will normally be the same object as .compile_state, with the exception of cases like the
ORMFromStatementCompileState
object.New in version 1.4.40.
-
attribute
sqlalchemy.engine.Compiled.
execution_options: _ExecuteOptions = {}¶ Execution options propagated from the statement. In some cases, sub-elements of the statement can modify these.
-
attribute
sqlalchemy.engine.Compiled.
params¶ Return the bind params for this compiled object.
-
attribute
sqlalchemy.engine.Compiled.
sql_compiler¶ Return a Compiled that is capable of processing SQL expressions.
If this compiler is one, it would likely just return ‘self’.
-
attribute
sqlalchemy.engine.Compiled.
state: CompilerState¶ description of the compiler’s state
-
attribute
sqlalchemy.engine.Compiled.
statement: ClauseElement | None = None¶ The statement to compile.
-
attribute
sqlalchemy.engine.Compiled.
string: str = ''¶ The string representation of the
statement
-
method
- class sqlalchemy.engine.interfaces.DBAPIConnection¶
protocol representing a PEP 249 database connection.
New in version 2.0.
See also
Members
Class signature
class
sqlalchemy.engine.interfaces.DBAPIConnection
(typing.Protocol
)-
attribute
sqlalchemy.engine.interfaces.DBAPIConnection.
autocommit: bool¶
-
method
sqlalchemy.engine.interfaces.DBAPIConnection.
close() → None¶
-
method
sqlalchemy.engine.interfaces.DBAPIConnection.
commit() → None¶
-
method
sqlalchemy.engine.interfaces.DBAPIConnection.
cursor() → DBAPICursor¶
-
method
sqlalchemy.engine.interfaces.DBAPIConnection.
rollback() → None¶
-
attribute
- class sqlalchemy.engine.interfaces.DBAPICursor¶
protocol representing a PEP 249 database cursor.
New in version 2.0.
See also
Cursor Objects - in PEP 249
Members
arraysize, callproc(), close(), description, execute(), executemany(), fetchall(), fetchmany(), fetchone(), lastrowid, nextset(), rowcount, setinputsizes(), setoutputsize()
Class signature
class
sqlalchemy.engine.interfaces.DBAPICursor
(typing.Protocol
)-
attribute
sqlalchemy.engine.interfaces.DBAPICursor.
arraysize: int¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
callproc(procname: str, parameters: Sequence[Any] = Ellipsis) → Any¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
close() → None¶
-
attribute
sqlalchemy.engine.interfaces.DBAPICursor.
description¶ The description attribute of the Cursor.
See also
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
execute(operation: Any, parameters: Sequence[Any] | Mapping[str, Any] | None = None) → Any¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
executemany(operation: Any, parameters: Sequence[Sequence[Any]] | Sequence[Mapping[str, Any]]) → Any¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
fetchall() → Sequence[Any]¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
fetchmany(size: int = Ellipsis) → Sequence[Any]¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
fetchone() → Any | None¶
-
attribute
sqlalchemy.engine.interfaces.DBAPICursor.
lastrowid: int¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
nextset() → bool | None¶
-
attribute
sqlalchemy.engine.interfaces.DBAPICursor.
rowcount¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
setinputsizes(sizes: Sequence[Any]) → None¶
-
method
sqlalchemy.engine.interfaces.DBAPICursor.
setoutputsize(size: Any, column: Any) → None¶
-
attribute
- class sqlalchemy.engine.interfaces.DBAPIType¶
protocol representing a PEP 249 database type.
New in version 2.0.
See also
Type Objects - in PEP 249
Class signature
class
sqlalchemy.engine.interfaces.DBAPIType
(typing.Protocol
)
- class sqlalchemy.sql.compiler.DDLCompiler¶
Members
__init__(), cache_key, compile_state, construct_params(), define_constraint_remote_table(), dml_compile_state, execution_options, params, sql_compiler, state, statement, string
Class signature
class
sqlalchemy.sql.compiler.DDLCompiler
(sqlalchemy.sql.compiler.Compiled
)-
method
sqlalchemy.sql.compiler.DDLCompiler.
__init__(dialect: Dialect, statement: ClauseElement | None, schema_translate_map: SchemaTranslateMapType | None = None, render_schema_translate: bool = False, compile_kwargs: Mapping[str, Any] = {})¶ inherited from the
sqlalchemy.sql.compiler.Compiled.__init__
method ofCompiled
Construct a new
Compiled
object.- Parameters:
statement¶ –
ClauseElement
to be compiled.schema_translate_map¶ –
dictionary of schema names to be translated when forming the resultant SQL
See also
compile_kwargs¶ – additional kwargs that will be passed to the initial call to
Compiled.process()
.
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
cache_key: CacheKey | None = None¶ inherited from the
Compiled.cache_key
attribute ofCompiled
The
CacheKey
that was generated ahead of creating thisCompiled
object.This is used for routines that need access to the original
CacheKey
instance generated when theCompiled
instance was first cached, typically in order to reconcile the original list ofBindParameter
objects with a per-statement list that’s generated on each call.
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
compile_state: CompileState | None = None¶ inherited from the
Compiled.compile_state
attribute ofCompiled
Optional
CompileState
object that maintains additional state used by the compiler.Major executable objects such as
Insert
,Update
,Delete
,Select
will generate this state when compiled in order to calculate additional information about the object. For the top level object that is to be executed, the state can be stored here where it can also have applicability towards result set processing.New in version 1.4.
-
method
sqlalchemy.sql.compiler.DDLCompiler.
construct_params(params: _CoreSingleExecuteParams | None = None, extracted_parameters: Sequence[BindParameter[Any]] | None = None, escape_names: bool = True) → _MutableCoreSingleExecuteParams | None¶ Return the bind params for this compiled object.
- Parameters:
params¶ – a dict of string/object pairs whose values will override bind values compiled in to the statement.
-
method
sqlalchemy.sql.compiler.DDLCompiler.
define_constraint_remote_table(constraint, table, preparer)¶ Format the remote table clause of a CREATE CONSTRAINT clause.
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
dml_compile_state: CompileState | None = None¶ inherited from the
Compiled.dml_compile_state
attribute ofCompiled
Optional
CompileState
assigned at the same point that .isinsert, .isupdate, or .isdelete is assigned.This will normally be the same object as .compile_state, with the exception of cases like the
ORMFromStatementCompileState
object.New in version 1.4.40.
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
execution_options: _ExecuteOptions = {}¶ inherited from the
Compiled.execution_options
attribute ofCompiled
Execution options propagated from the statement. In some cases, sub-elements of the statement can modify these.
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
params¶ inherited from the
Compiled.params
attribute ofCompiled
Return the bind params for this compiled object.
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
sql_compiler¶
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
state: CompilerState¶ description of the compiler’s state
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
statement: ClauseElement | None = None¶ inherited from the
Compiled.statement
attribute ofCompiled
The statement to compile.
-
attribute
sqlalchemy.sql.compiler.DDLCompiler.
string: str = ''¶ inherited from the
Compiled.string
attribute ofCompiled
The string representation of the
statement
-
method
- class sqlalchemy.engine.default.DefaultDialect¶
Default implementation of Dialect
Members
bind_typing, colspecs, connect(), construct_arguments, create_connect_args(), create_xid(), cte_follows_insert, dbapi, dbapi_exception_translation_map, ddl_compiler, default_isolation_level, default_metavalue_token, default_schema_name, default_sequence_base, delete_executemany_returning, delete_returning, delete_returning_multifrom, denormalize_name(), div_is_floordiv, do_begin(), do_begin_twophase(), do_close(), do_commit(), do_commit_twophase(), do_execute(), do_execute_no_params(), do_executemany(), do_ping(), do_prepare_twophase(), do_recover_twophase(), do_release_savepoint(), do_rollback(), do_rollback_to_savepoint(), do_rollback_twophase(), do_savepoint(), do_set_input_sizes(), do_terminate(), driver, engine_config_types, engine_created(), exclude_set_input_sizes, execute_sequence_format, execution_ctx_cls, favor_returning_over_lastrowid, full_returning, get_async_dialect_cls(), get_check_constraints(), get_columns(), get_default_isolation_level(), get_dialect_cls(), get_dialect_pool_class(), get_driver_connection(), get_foreign_keys(), get_indexes(), get_isolation_level(), get_isolation_level_values(), get_materialized_view_names(), get_multi_check_constraints(), get_multi_columns(), get_multi_foreign_keys(), get_multi_indexes(), get_multi_pk_constraint(), get_multi_table_comment(), get_multi_table_options(), get_multi_unique_constraints(), get_pk_constraint(), get_schema_names(), get_sequence_names(), get_table_comment(), get_table_names(), get_table_options(), get_temp_table_names(), get_temp_view_names(), get_unique_constraints(), get_view_definition(), get_view_names(), has_index(), has_schema(), has_sequence(), has_table(), has_terminate, identifier_preparer, import_dbapi(), include_set_input_sizes, initialize(), inline_comments, insert_executemany_returning, insert_executemany_returning_sort_by_parameter_order, insert_returning, insertmanyvalues_implicit_sentinel, insertmanyvalues_max_parameters, insertmanyvalues_page_size, is_async, is_disconnect(), label_length, load_provisioning(), loaded_dbapi, max_identifier_length, name, normalize_name(), on_connect(), on_connect_url(), paramstyle, positional, preexecute_autoincrement_sequences, preparer, reflection_options, reset_isolation_level(), returns_native_bytes, sequences_optional, server_side_cursors, server_version_info, set_connection_execution_options(), set_engine_execution_options(), set_isolation_level(), statement_compiler, supports_alter, supports_comments, supports_constraint_comments, supports_default_metavalue, supports_default_values, supports_empty_insert, supports_identity_columns, supports_multivalues_insert, supports_native_boolean, supports_native_decimal, supports_native_enum, supports_native_uuid, supports_sane_multi_rowcount, supports_sane_rowcount, supports_sane_rowcount_returning, supports_sequences, supports_server_side_cursors, supports_simple_order_by_label, supports_statement_cache, tuple_in_values, type_compiler, type_compiler_cls, type_compiler_instance, type_descriptor(), update_executemany_returning, update_returning, update_returning_multifrom, use_insertmanyvalues, use_insertmanyvalues_wo_returning
Class signature
class
sqlalchemy.engine.default.DefaultDialect
(sqlalchemy.engine.interfaces.Dialect
)-
attribute
sqlalchemy.engine.default.DefaultDialect.
bind_typing = 1¶ define a means of passing typing information to the database and/or driver for bound parameters.
See
BindTyping
for values.New in version 2.0.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
colspecs: MutableMapping[Type[TypeEngine[Any]], Type[TypeEngine[Any]]] = {}¶ A dictionary of TypeEngine classes from sqlalchemy.types mapped to subclasses that are specific to the dialect class. This dictionary is class-level only and is not accessed from the dialect instance itself.
-
method
sqlalchemy.engine.default.DefaultDialect.
connect(*cargs, **cparams)¶ Establish a connection using this dialect’s DBAPI.
The default implementation of this method is:
def connect(self, *cargs, **cparams): return self.dbapi.connect(*cargs, **cparams)
The
*cargs, **cparams
parameters are generated directly from this dialect’sDialect.create_connect_args()
method.This method may be used for dialects that need to perform programmatic per-connection steps when a new connection is procured from the DBAPI.
- Parameters:
*cargs¶ – positional parameters returned from the
Dialect.create_connect_args()
method**cparams¶ – keyword parameters returned from the
Dialect.create_connect_args()
method.
- Returns:
a DBAPI connection, typically from the PEP 249 module level
.connect()
function.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
construct_arguments: List[Tuple[Type[SchemaItem | ClauseElement], Mapping[str, Any]]] | None = None¶ inherited from the
Dialect.construct_arguments
attribute ofDialect
Optional set of argument specifiers for various SQLAlchemy constructs, typically schema items.
To implement, establish as a series of tuples, as in:
construct_arguments = [ (schema.Index, { "using": False, "where": None, "ops": None }) ]
If the above construct is established on the PostgreSQL dialect, the
Index
construct will now accept the keyword argumentspostgresql_using
,postgresql_where
, nadpostgresql_ops
. Any other argument specified to the constructor ofIndex
which is prefixed withpostgresql_
will raiseArgumentError
.A dialect which does not include a
construct_arguments
member will not participate in the argument validation system. For such a dialect, any argument name is accepted by all participating constructs, within the namespace of arguments prefixed with that dialect name. The rationale here is so that third-party dialects that haven’t yet implemented this feature continue to function in the old way.See also
DialectKWArgs
- implementing base class which consumesDefaultDialect.construct_arguments
-
method
sqlalchemy.engine.default.DefaultDialect.
create_connect_args(url)¶ Build DB-API compatible connection arguments.
Given a
URL
object, returns a tuple consisting of a(*args, **kwargs)
suitable to send directly to the dbapi’s connect function. The arguments are sent to theDialect.connect()
method which then runs the DBAPI-levelconnect()
function.The method typically makes use of the
URL.translate_connect_args()
method in order to generate a dictionary of options.The default implementation is:
def create_connect_args(self, url): opts = url.translate_connect_args() opts.update(url.query) return ([], opts)
- Parameters:
- Returns:
a tuple of
(*args, **kwargs)
which will be passed to theDialect.connect()
method.
See also
-
method
sqlalchemy.engine.default.DefaultDialect.
create_xid()¶ Create a random two-phase transaction ID.
This id will be passed to do_begin_twophase(), do_rollback_twophase(), do_commit_twophase(). Its format is unspecified.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
cte_follows_insert: bool = False¶ target database, when given a CTE with an INSERT statement, needs the CTE to be below the INSERT
-
attribute
sqlalchemy.engine.default.DefaultDialect.
dbapi: ModuleType | None¶ A reference to the DBAPI module object itself.
SQLAlchemy dialects import DBAPI modules using the classmethod
Dialect.import_dbapi()
. The rationale is so that any dialect module can be imported and used to generate SQL statements without the need for the actual DBAPI driver to be installed. Only when anEngine
is constructed usingcreate_engine()
does the DBAPI get imported; at that point, the creation process will assign the DBAPI module to this attribute.Dialects should therefore implement
Dialect.import_dbapi()
which will import the necessary module and return it, and then refer toself.dbapi
in dialect code in order to refer to the DBAPI module contents.Changed in version The:
Dialect.dbapi
attribute is exclusively used as the per-Dialect
-instance reference to the DBAPI module. The previous not-fully-documented.Dialect.dbapi()
classmethod is deprecated and replaced byDialect.import_dbapi()
.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
dbapi_exception_translation_map: Mapping[str, str] = {}¶ inherited from the
Dialect.dbapi_exception_translation_map
attribute ofDialect
A dictionary of names that will contain as values the names of pep-249 exceptions (“IntegrityError”, “OperationalError”, etc) keyed to alternate class names, to support the case where a DBAPI has exception classes that aren’t named as they are referred to (e.g. IntegrityError = MyException). In the vast majority of cases this dictionary is empty.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
ddl_compiler¶ alias of
DDLCompiler
-
attribute
sqlalchemy.engine.default.DefaultDialect.
default_isolation_level: IsolationLevel | None¶ the isolation that is implicitly present on new connections
-
attribute
sqlalchemy.engine.default.DefaultDialect.
default_metavalue_token: str = 'DEFAULT'¶ for INSERT… VALUES (DEFAULT) syntax, the token to put in the parenthesis.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
default_schema_name: str | None = None¶ the name of the default schema. This value is only available for supporting dialects, and is typically populated during the initial connection to the database.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
default_sequence_base: int = 1¶ the default value that will be rendered as the “START WITH” portion of a CREATE SEQUENCE DDL statement.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
delete_executemany_returning: bool = False¶ dialect supports DELETE..RETURNING with executemany.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
delete_returning: bool = False¶ if the dialect supports RETURNING with DELETE
New in version 2.0.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
delete_returning_multifrom: bool = False¶ if the dialect supports RETURNING with DELETE..FROM
New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
denormalize_name(name)¶ convert the given name to a case insensitive identifier for the backend if it is an all-lowercase name.
This method is only used if the dialect defines requires_name_normalize=True.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
div_is_floordiv: bool = True¶ target database treats the / division operator as “floor division”
-
method
sqlalchemy.engine.default.DefaultDialect.
do_begin(dbapi_connection)¶ Provide an implementation of
connection.begin()
, given a DB-API connection.The DBAPI has no dedicated “begin” method and it is expected that transactions are implicit. This hook is provided for those DBAPIs that might need additional help in this area.
- Parameters:
dbapi_connection¶ – a DBAPI connection, typically proxied within a
ConnectionFairy
.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_begin_twophase(connection: Connection, xid: Any) → None¶ inherited from the
Dialect.do_begin_twophase()
method ofDialect
Begin a two phase transaction on the given connection.
- Parameters:
connection¶ – a
Connection
.xid¶ – xid
-
method
sqlalchemy.engine.default.DefaultDialect.
do_close(dbapi_connection)¶ Provide an implementation of
connection.close()
, given a DBAPI connection.This hook is called by the
Pool
when a connection has been detached from the pool, or is being returned beyond the normal capacity of the pool.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_commit(dbapi_connection)¶ Provide an implementation of
connection.commit()
, given a DB-API connection.- Parameters:
dbapi_connection¶ – a DBAPI connection, typically proxied within a
ConnectionFairy
.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_commit_twophase(connection: Connection, xid: Any, is_prepared: bool = True, recover: bool = False) → None¶ inherited from the
Dialect.do_commit_twophase()
method ofDialect
Commit a two phase transaction on the given connection.
- Parameters:
connection¶ – a
Connection
.xid¶ – xid
is_prepared¶ – whether or not
TwoPhaseTransaction.prepare()
was called.recover¶ – if the recover flag was passed.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_execute(cursor, statement, parameters, context=None)¶ Provide an implementation of
cursor.execute(statement, parameters)
.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_execute_no_params(cursor, statement, context=None)¶ Provide an implementation of
cursor.execute(statement)
.The parameter collection should not be sent.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_executemany(cursor, statement, parameters, context=None)¶ Provide an implementation of
cursor.executemany(statement, parameters)
.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_ping(dbapi_connection: DBAPIConnection) → bool¶ ping the DBAPI connection and return True if the connection is usable.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_prepare_twophase(connection: Connection, xid: Any) → None¶ inherited from the
Dialect.do_prepare_twophase()
method ofDialect
Prepare a two phase transaction on the given connection.
- Parameters:
connection¶ – a
Connection
.xid¶ – xid
-
method
sqlalchemy.engine.default.DefaultDialect.
do_recover_twophase(connection: Connection) → List[Any]¶ inherited from the
Dialect.do_recover_twophase()
method ofDialect
Recover list of uncommitted prepared two phase transaction identifiers on the given connection.
- Parameters:
connection¶ – a
Connection
.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_release_savepoint(connection, name)¶ Release the named savepoint on a connection.
- Parameters:
connection¶ – a
Connection
.name¶ – savepoint name.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_rollback(dbapi_connection)¶ Provide an implementation of
connection.rollback()
, given a DB-API connection.- Parameters:
dbapi_connection¶ – a DBAPI connection, typically proxied within a
ConnectionFairy
.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_rollback_to_savepoint(connection, name)¶ Rollback a connection to the named savepoint.
- Parameters:
connection¶ – a
Connection
.name¶ – savepoint name.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_rollback_twophase(connection: Connection, xid: Any, is_prepared: bool = True, recover: bool = False) → None¶ inherited from the
Dialect.do_rollback_twophase()
method ofDialect
Rollback a two phase transaction on the given connection.
- Parameters:
connection¶ – a
Connection
.xid¶ – xid
is_prepared¶ – whether or not
TwoPhaseTransaction.prepare()
was called.recover¶ – if the recover flag was passed.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_savepoint(connection, name)¶ Create a savepoint with the given name.
- Parameters:
connection¶ – a
Connection
.name¶ – savepoint name.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_set_input_sizes(cursor: DBAPICursor, list_of_tuples: _GenericSetInputSizesType, context: ExecutionContext) → Any¶ inherited from the
Dialect.do_set_input_sizes()
method ofDialect
invoke the cursor.setinputsizes() method with appropriate arguments
This hook is called if the
Dialect.bind_typing
attribute is set to theBindTyping.SETINPUTSIZES
value. Parameter data is passed in a list of tuples (paramname, dbtype, sqltype), whereparamname
is the key of the parameter in the statement,dbtype
is the DBAPI datatype andsqltype
is the SQLAlchemy type. The order of tuples is in the correct parameter order.New in version 1.4.
Changed in version 2.0: - setinputsizes mode is now enabled by setting
Dialect.bind_typing
toBindTyping.SETINPUTSIZES
. Dialects which accept ause_setinputsizes
parameter should set this value appropriately.
-
method
sqlalchemy.engine.default.DefaultDialect.
do_terminate(dbapi_connection)¶ Provide an implementation of
connection.close()
that tries as much as possible to not block, given a DBAPI connection.In the vast majority of cases this just calls .close(), however for some asyncio dialects may call upon different API features.
This hook is called by the
Pool
when a connection is being recycled or has been invalidated.New in version 1.4.41.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
driver: str¶ identifying name for the dialect’s DBAPI
-
attribute
sqlalchemy.engine.default.DefaultDialect.
engine_config_types: Mapping[str, Any] = {'echo': <function bool_or_str.<locals>.bool_or_value>, 'echo_pool': <function bool_or_str.<locals>.bool_or_value>, 'future': <function asbool>, 'max_overflow': <function asint>, 'pool_recycle': <function asint>, 'pool_size': <function asint>, 'pool_timeout': <function asint>}¶ a mapping of string keys that can be in an engine config linked to type conversion functions.
-
classmethod
sqlalchemy.engine.default.DefaultDialect.
engine_created(engine: Engine) → None¶ inherited from the
Dialect.engine_created()
method ofDialect
A convenience hook called before returning the final
Engine
.If the dialect returned a different class from the
get_dialect_cls()
method, then the hook is called on both classes, first on the dialect class returned by theget_dialect_cls()
method and then on the class on which the method was called.The hook should be used by dialects and/or wrappers to apply special events to the engine or its components. In particular, it allows a dialect-wrapping class to apply dialect-level events.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
exclude_set_input_sizes: Set[Any] | None = None¶ set of DBAPI type objects that should be excluded in automatic cursor.setinputsizes() calls.
This is only used if bind_typing is BindTyping.SET_INPUT_SIZES
-
attribute
sqlalchemy.engine.default.DefaultDialect.
execute_sequence_format¶ alias of
tuple
-
attribute
sqlalchemy.engine.default.DefaultDialect.
execution_ctx_cls¶ alias of
DefaultExecutionContext
-
attribute
sqlalchemy.engine.default.DefaultDialect.
favor_returning_over_lastrowid: bool = False¶ for backends that support both a lastrowid and a RETURNING insert strategy, favor RETURNING for simple single-int pk inserts.
cursor.lastrowid tends to be more performant on most backends.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
full_returning¶ Deprecated since version 2.0: full_returning is deprecated, please use insert_returning, update_returning, delete_returning
-
classmethod
sqlalchemy.engine.default.DefaultDialect.
get_async_dialect_cls(url: URL) → Type[Dialect]¶ inherited from the
Dialect.get_async_dialect_cls()
method ofDialect
Given a URL, return the
Dialect
that will be used by an async engine.By default this is an alias of
Dialect.get_dialect_cls()
and just returns the cls. It may be used if a dialect provides both a sync and async version under the same name, like thepsycopg
driver.New in version 2.
See also
-
method
sqlalchemy.engine.default.DefaultDialect.
get_check_constraints(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedCheckConstraint]¶ inherited from the
Dialect.get_check_constraints()
method ofDialect
Return information about check constraints in
table_name
.Given a string
table_name
and an optional stringschema
, return check constraint information as a list of dicts corresponding to theReflectedCheckConstraint
dictionary.This is an internal dialect method. Applications should use
Inspector.get_check_constraints()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_columns(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedColumn]¶ inherited from the
Dialect.get_columns()
method ofDialect
Return information about columns in
table_name
.Given a
Connection
, a stringtable_name
, and an optional stringschema
, return column information as a list of dictionaries corresponding to theReflectedColumn
dictionary.This is an internal dialect method. Applications should use
Inspector.get_columns()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_default_isolation_level(dbapi_conn)¶ Given a DBAPI connection, return its isolation level, or a default isolation level if one cannot be retrieved.
May be overridden by subclasses in order to provide a “fallback” isolation level for databases that cannot reliably retrieve the actual isolation level.
By default, calls the
Interfaces.get_isolation_level()
method, propagating any exceptions raised.New in version 1.3.22.
-
classmethod
sqlalchemy.engine.default.DefaultDialect.
get_dialect_cls(url: URL) → Type[Dialect]¶ inherited from the
Dialect.get_dialect_cls()
method ofDialect
Given a URL, return the
Dialect
that will be used.This is a hook that allows an external plugin to provide functionality around an existing dialect, by allowing the plugin to be loaded from the url based on an entrypoint, and then the plugin returns the actual dialect to be used.
By default this just returns the cls.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_dialect_pool_class(url: URL) → Type[Pool]¶ return a Pool class to use for a given URL
-
method
sqlalchemy.engine.default.DefaultDialect.
get_driver_connection(connection)¶ Returns the connection object as returned by the external driver package.
For normal dialects that use a DBAPI compliant driver this call will just return the
connection
passed as argument. For dialects that instead adapt a non DBAPI compliant driver, like when adapting an asyncio driver, this call will return the connection-like object as returned by the driver.New in version 1.4.24.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_foreign_keys(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedForeignKeyConstraint]¶ inherited from the
Dialect.get_foreign_keys()
method ofDialect
Return information about foreign_keys in
table_name
.Given a
Connection
, a stringtable_name
, and an optional stringschema
, return foreign key information as a list of dicts corresponding to theReflectedForeignKeyConstraint
dictionary.This is an internal dialect method. Applications should use
Inspector.get_foreign_keys()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_indexes(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedIndex]¶ inherited from the
Dialect.get_indexes()
method ofDialect
Return information about indexes in
table_name
.Given a
Connection
, a stringtable_name
and an optional stringschema
, return index information as a list of dictionaries corresponding to theReflectedIndex
dictionary.This is an internal dialect method. Applications should use
Inspector.get_indexes()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_isolation_level(dbapi_connection: DBAPIConnection) → Literal['SERIALIZABLE', 'REPEATABLE READ', 'READ COMMITTED', 'READ UNCOMMITTED', 'AUTOCOMMIT']¶ inherited from the
Dialect.get_isolation_level()
method ofDialect
Given a DBAPI connection, return its isolation level.
When working with a
Connection
object, the corresponding DBAPI connection may be procured using theConnection.connection
accessor.Note that this is a dialect-level method which is used as part of the implementation of the
Connection
andEngine
isolation level facilities; these APIs should be preferred for most typical use cases.See also
Connection.get_isolation_level()
- view current levelConnection.default_isolation_level
- view default levelConnection.execution_options.isolation_level
- set perConnection
isolation levelcreate_engine.isolation_level
- set perEngine
isolation level
-
method
sqlalchemy.engine.default.DefaultDialect.
get_isolation_level_values(dbapi_conn: DBAPIConnection) → List[Literal['SERIALIZABLE', 'REPEATABLE READ', 'READ COMMITTED', 'READ UNCOMMITTED', 'AUTOCOMMIT']]¶ inherited from the
Dialect.get_isolation_level_values()
method ofDialect
return a sequence of string isolation level names that are accepted by this dialect.
The available names should use the following conventions:
use UPPERCASE names. isolation level methods will accept lowercase names but these are normalized into UPPERCASE before being passed along to the dialect.
separate words should be separated by spaces, not underscores, e.g.
REPEATABLE READ
. isolation level names will have underscores converted to spaces before being passed along to the dialect.The names for the four standard isolation names to the extent that they are supported by the backend should be
READ UNCOMMITTED
READ COMMITTED
,REPEATABLE READ
,SERIALIZABLE
if the dialect supports an autocommit option it should be provided using the isolation level name
AUTOCOMMIT
.Other isolation modes may also be present, provided that they are named in UPPERCASE and use spaces not underscores.
This function is used so that the default dialect can check that a given isolation level parameter is valid, else raises an
ArgumentError
.A DBAPI connection is passed to the method, in the unlikely event that the dialect needs to interrogate the connection itself to determine this list, however it is expected that most backends will return a hardcoded list of values. If the dialect supports “AUTOCOMMIT”, that value should also be present in the sequence returned.
The method raises
NotImplementedError
by default. If a dialect does not implement this method, then the default dialect will not perform any checking on a given isolation level value before passing it onto theDialect.set_isolation_level()
method. This is to allow backwards-compatibility with third party dialects that may not yet be implementing this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_materialized_view_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ inherited from the
Dialect.get_materialized_view_names()
method ofDialect
Return a list of all materialized view names available in the database.
This is an internal dialect method. Applications should use
Inspector.get_materialized_view_names()
.- Parameters:
schema¶ –
schema name to query, if not the default schema.
New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_multi_check_constraints(connection, **kw)¶ Return information about check constraints in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_check_constraints()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_multi_columns(connection, **kw)¶ Return information about columns in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_columns()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_multi_foreign_keys(connection, **kw)¶ Return information about foreign_keys in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_foreign_keys()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_multi_indexes(connection, **kw)¶ Return information about indexes in in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_indexes()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_multi_pk_constraint(connection, **kw)¶ Return information about primary key constraints in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_pk_constraint()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_multi_table_comment(connection, **kw)¶ Return information about the table comment in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_table_comment()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_multi_table_options(connection, **kw)¶ Return a dictionary of options specified when the tables in the given schema were created.
This is an internal dialect method. Applications should use
Inspector.get_multi_table_options()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_multi_unique_constraints(connection, **kw)¶ Return information about unique constraints in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_unique_constraints()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_pk_constraint(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → ReflectedPrimaryKeyConstraint¶ inherited from the
Dialect.get_pk_constraint()
method ofDialect
Return information about the primary key constraint on table_name`.
Given a
Connection
, a stringtable_name
, and an optional stringschema
, return primary key information as a dictionary corresponding to theReflectedPrimaryKeyConstraint
dictionary.This is an internal dialect method. Applications should use
Inspector.get_pk_constraint()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_schema_names(connection: Connection, **kw: Any) → List[str]¶ inherited from the
Dialect.get_schema_names()
method ofDialect
Return a list of all schema names available in the database.
This is an internal dialect method. Applications should use
Inspector.get_schema_names()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_sequence_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ inherited from the
Dialect.get_sequence_names()
method ofDialect
Return a list of all sequence names available in the database.
This is an internal dialect method. Applications should use
Inspector.get_sequence_names()
.- Parameters:
schema¶ – schema name to query, if not the default schema.
New in version 1.4.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_table_comment(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → ReflectedTableComment¶ inherited from the
Dialect.get_table_comment()
method ofDialect
Return the “comment” for the table identified by
table_name
.Given a string
table_name
and an optional stringschema
, return table comment information as a dictionary corresponding to theReflectedTableComment
dictionary.This is an internal dialect method. Applications should use
Inspector.get_table_comment()
.- Raise:
NotImplementedError
for dialects that don’t support comments.
New in version 1.2.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_table_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ inherited from the
Dialect.get_table_names()
method ofDialect
Return a list of table names for
schema
.This is an internal dialect method. Applications should use
Inspector.get_table_names()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_table_options(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → Dict[str, Any]¶ inherited from the
Dialect.get_table_options()
method ofDialect
Return a dictionary of options specified when
table_name
was created.This is an internal dialect method. Applications should use
Inspector.get_table_options()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_temp_table_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ inherited from the
Dialect.get_temp_table_names()
method ofDialect
Return a list of temporary table names on the given connection, if supported by the underlying backend.
This is an internal dialect method. Applications should use
Inspector.get_temp_table_names()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_temp_view_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ inherited from the
Dialect.get_temp_view_names()
method ofDialect
Return a list of temporary view names on the given connection, if supported by the underlying backend.
This is an internal dialect method. Applications should use
Inspector.get_temp_view_names()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_unique_constraints(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedUniqueConstraint]¶ inherited from the
Dialect.get_unique_constraints()
method ofDialect
Return information about unique constraints in
table_name
.Given a string
table_name
and an optional stringschema
, return unique constraint information as a list of dicts corresponding to theReflectedUniqueConstraint
dictionary.This is an internal dialect method. Applications should use
Inspector.get_unique_constraints()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_view_definition(connection: Connection, view_name: str, schema: str | None = None, **kw: Any) → str¶ inherited from the
Dialect.get_view_definition()
method ofDialect
Return plain or materialized view definition.
This is an internal dialect method. Applications should use
Inspector.get_view_definition()
.Given a
Connection
, a stringview_name
, and an optional stringschema
, return the view definition.
-
method
sqlalchemy.engine.default.DefaultDialect.
get_view_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ inherited from the
Dialect.get_view_names()
method ofDialect
Return a list of all non-materialized view names available in the database.
This is an internal dialect method. Applications should use
Inspector.get_view_names()
.- Parameters:
schema¶ – schema name to query, if not the default schema.
-
method
sqlalchemy.engine.default.DefaultDialect.
has_index(connection, table_name, index_name, schema=None, **kw)¶ Check the existence of a particular index name in the database.
Given a
Connection
object, a stringtable_name
and string index name, returnTrue
if an index of the given name on the given table exists,False
otherwise.The
DefaultDialect
implements this in terms of theDialect.has_table()
andDialect.get_indexes()
methods, however dialects can implement a more performant version.This is an internal dialect method. Applications should use
Inspector.has_index()
.New in version 1.4.
-
method
sqlalchemy.engine.default.DefaultDialect.
has_schema(connection: Connection, schema_name: str, **kw: Any) → bool¶ Check the existence of a particular schema name in the database.
Given a
Connection
object, a stringschema_name
, returnTrue
if a schema of the given exists,False
otherwise.The
DefaultDialect
implements this by checking the presence ofschema_name
among the schemas returned byDialect.get_schema_names()
, however dialects can implement a more performant version.This is an internal dialect method. Applications should use
Inspector.has_schema()
.New in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
has_sequence(connection: Connection, sequence_name: str, schema: str | None = None, **kw: Any) → bool¶ inherited from the
Dialect.has_sequence()
method ofDialect
Check the existence of a particular sequence in the database.
Given a
Connection
object and a string sequence_name, returnTrue
if the given sequence exists in the database,False
otherwise.This is an internal dialect method. Applications should use
Inspector.has_sequence()
.
-
method
sqlalchemy.engine.default.DefaultDialect.
has_table(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → bool¶ inherited from the
Dialect.has_table()
method ofDialect
For internal dialect use, check the existence of a particular table or view in the database.
Given a
Connection
object, a string table_name and optional schema name, return True if the given table exists in the database, False otherwise.This method serves as the underlying implementation of the public facing
Inspector.has_table()
method, and is also used internally to implement the “checkfirst” behavior for methods likeTable.create()
andMetaData.create_all()
.Note
This method is used internally by SQLAlchemy, and is published so that third-party dialects may provide an implementation. It is not the public API for checking for table presence. Please use the
Inspector.has_table()
method.Changed in version 2.0:::
Dialect.has_table()
now formally supports checking for additional table-like objects:any type of views (plain or materialized)
temporary tables of any kind
Previously, these two checks were not formally specified and different dialects would vary in their behavior. The dialect testing suite now includes tests for all of these object types, and dialects to the degree that the backing database supports views or temporary tables should seek to support locating these objects for full compliance.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
has_terminate: bool = False¶ Whether or not this dialect has a separate “terminate” implementation that does not block or require awaiting.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
identifier_preparer: IdentifierPreparer¶ This element will refer to an instance of
IdentifierPreparer
once aDefaultDialect
has been constructed.
-
classmethod
sqlalchemy.engine.default.DefaultDialect.
import_dbapi() → module¶ inherited from the
Dialect.import_dbapi()
method ofDialect
Import the DBAPI module that is used by this dialect.
The Python module object returned here will be assigned as an instance variable to a constructed dialect under the name
.dbapi
.Changed in version 2.0: The
Dialect.import_dbapi()
class method is renamed from the previous method.Dialect.dbapi()
, which would be replaced at dialect instantiation time by the DBAPI module itself, thus using the same name in two different ways. If a.Dialect.dbapi()
classmethod is present on a third-party dialect, it will be used and a deprecation warning will be emitted.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
include_set_input_sizes: Set[Any] | None = None¶ set of DBAPI type objects that should be included in automatic cursor.setinputsizes() calls.
This is only used if bind_typing is BindTyping.SET_INPUT_SIZES
-
method
sqlalchemy.engine.default.DefaultDialect.
initialize(connection)¶ Called during strategized creation of the dialect with a connection.
Allows dialects to configure options based on server version info or other properties.
The connection passed here is a SQLAlchemy Connection object, with full capabilities.
The initialize() method of the base dialect should be called via super().
Note
as of SQLAlchemy 1.4, this method is called before any
Dialect.on_connect()
hooks are called.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
inline_comments: bool = False¶ Indicates the dialect supports comment DDL that’s inline with the definition of a Table or Column. If False, this implies that ALTER must be used to set table and column comments.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
insert_executemany_returning: bool¶ dialect / driver / database supports some means of providing INSERT…RETURNING support when dialect.do_executemany() is used.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
insert_executemany_returning_sort_by_parameter_order: bool¶ dialect / driver / database supports some means of providing INSERT…RETURNING support when dialect.do_executemany() is used along with the
Insert.returning.sort_by_parameter_order
parameter being set.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
insert_returning: bool = False¶ if the dialect supports RETURNING with INSERT
New in version 2.0.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
insertmanyvalues_implicit_sentinel: InsertmanyvaluesSentinelOpts = symbol('NOT_SUPPORTED')¶ Options indicating the database supports a form of bulk INSERT where the autoincrement integer primary key can be reliably used as an ordering for INSERTed rows.
New in version 2.0.10.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
insertmanyvalues_max_parameters: int = 32700¶ Alternate to insertmanyvalues_page_size, will additionally limit page size based on number of parameters total in the statement.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
insertmanyvalues_page_size: int = 1000¶ Number of rows to render into an individual INSERT..VALUES() statement for
ExecuteStyle.INSERTMANYVALUES
executions.The default dialect defaults this to 1000.
New in version 2.0.
See also
Connection.execution_options.insertmanyvalues_page_size
- execution option available onConnection
, statements
-
attribute
sqlalchemy.engine.default.DefaultDialect.
is_async: bool = False¶ Whether or not this dialect is intended for asyncio use.
-
method
sqlalchemy.engine.default.DefaultDialect.
is_disconnect(e, connection, cursor)¶ Return True if the given DB-API error indicates an invalid connection
-
attribute
sqlalchemy.engine.default.DefaultDialect.
label_length: int | None¶ optional user-defined max length for SQL labels
-
classmethod
sqlalchemy.engine.default.DefaultDialect.
load_provisioning()¶ set up the provision.py module for this dialect.
For dialects that include a provision.py module that sets up provisioning followers, this method should initiate that process.
A typical implementation would be:
@classmethod def load_provisioning(cls): __import__("mydialect.provision")
The default method assumes a module named
provision.py
inside the owning package of the current dialect, based on the__module__
attribute:@classmethod def load_provisioning(cls): package = ".".join(cls.__module__.split(".")[0:-1]) try: __import__(package + ".provision") except ImportError: pass
New in version 1.3.14.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
loaded_dbapi¶
-
attribute
sqlalchemy.engine.default.DefaultDialect.
max_identifier_length: int = 9999¶ The maximum length of identifier names.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
name: str = 'default'¶ identifying name for the dialect from a DBAPI-neutral point of view (i.e. ‘sqlite’)
-
method
sqlalchemy.engine.default.DefaultDialect.
normalize_name(name)¶ convert the given name to lowercase if it is detected as case insensitive.
This method is only used if the dialect defines requires_name_normalize=True.
-
method
sqlalchemy.engine.default.DefaultDialect.
on_connect()¶ return a callable which sets up a newly created DBAPI connection.
The callable should accept a single argument “conn” which is the DBAPI connection itself. The inner callable has no return value.
E.g.:
class MyDialect(default.DefaultDialect): # ... def on_connect(self): def do_on_connect(connection): connection.execute("SET SPECIAL FLAGS etc") return do_on_connect
This is used to set dialect-wide per-connection options such as isolation modes, Unicode modes, etc.
The “do_on_connect” callable is invoked by using the
PoolEvents.connect()
event hook, then unwrapping the DBAPI connection and passing it into the callable.Changed in version 1.4: the on_connect hook is no longer called twice for the first connection of a dialect. The on_connect hook is still called before the
Dialect.initialize()
method however.Changed in version 1.4.3: the on_connect hook is invoked from a new method on_connect_url that passes the URL that was used to create the connect args. Dialects can implement on_connect_url instead of on_connect if they need the URL object that was used for the connection in order to get additional context.
If None is returned, no event listener is generated.
- Returns:
a callable that accepts a single DBAPI connection as an argument, or None.
See also
Dialect.connect()
- allows the DBAPIconnect()
sequence itself to be controlled.Dialect.on_connect_url()
- supersedesDialect.on_connect()
to also receive theURL
object in context.
-
method
sqlalchemy.engine.default.DefaultDialect.
on_connect_url(url: URL) → Callable[[Any], Any] | None¶ inherited from the
Dialect.on_connect_url()
method ofDialect
return a callable which sets up a newly created DBAPI connection.
This method is a new hook that supersedes the
Dialect.on_connect()
method when implemented by a dialect. When not implemented by a dialect, it invokes theDialect.on_connect()
method directly to maintain compatibility with existing dialects. There is no deprecation forDialect.on_connect()
expected.The callable should accept a single argument “conn” which is the DBAPI connection itself. The inner callable has no return value.
E.g.:
class MyDialect(default.DefaultDialect): # ... def on_connect_url(self, url): def do_on_connect(connection): connection.execute("SET SPECIAL FLAGS etc") return do_on_connect
This is used to set dialect-wide per-connection options such as isolation modes, Unicode modes, etc.
This method differs from
Dialect.on_connect()
in that it is passed theURL
object that’s relevant to the connect args. Normally the only way to get this is from theDialect.on_connect()
hook is to look on theEngine
itself, however this URL object may have been replaced by plugins.Note
The default implementation of
Dialect.on_connect_url()
is to invoke theDialect.on_connect()
method. Therefore if a dialect implements this method, theDialect.on_connect()
method will not be called unless the overriding dialect calls it directly from here.New in version 1.4.3: added
Dialect.on_connect_url()
which normally calls intoDialect.on_connect()
.- Parameters:
url¶ – a
URL
object representing theURL
that was passed to theDialect.create_connect_args()
method.- Returns:
a callable that accepts a single DBAPI connection as an argument, or None.
See also
-
attribute
sqlalchemy.engine.default.DefaultDialect.
paramstyle: str¶ the paramstyle to be used (some DB-APIs support multiple paramstyles).
-
attribute
sqlalchemy.engine.default.DefaultDialect.
positional: bool¶ True if the paramstyle for this Dialect is positional.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
preexecute_autoincrement_sequences: bool = False¶ True if ‘implicit’ primary key functions must be executed separately in order to get their value, if RETURNING is not used.
This is currently oriented towards PostgreSQL when the
implicit_returning=False
parameter is used on aTable
object.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
preparer¶ alias of
IdentifierPreparer
-
attribute
sqlalchemy.engine.default.DefaultDialect.
reflection_options: Sequence[str] = ()¶ inherited from the
Dialect.reflection_options
attribute ofDialect
Sequence of string names indicating keyword arguments that can be established on a
Table
object which will be passed as “reflection options” when usingTable.autoload_with
.Current example is “oracle_resolve_synonyms” in the Oracle dialect.
-
method
sqlalchemy.engine.default.DefaultDialect.
reset_isolation_level(dbapi_conn)¶ Given a DBAPI connection, revert its isolation to the default.
Note that this is a dialect-level method which is used as part of the implementation of the
Connection
andEngine
isolation level facilities; these APIs should be preferred for most typical use cases.See also
Connection.get_isolation_level()
- view current levelConnection.default_isolation_level
- view default levelConnection.execution_options.isolation_level
- set perConnection
isolation levelcreate_engine.isolation_level
- set perEngine
isolation level
-
attribute
sqlalchemy.engine.default.DefaultDialect.
returns_native_bytes: bool = False¶ indicates if Python bytes() objects are returned natively by the driver for SQL “binary” datatypes.
New in version 2.0.11.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
sequences_optional: bool = False¶ If True, indicates if the
Sequence.optional
parameter on theSequence
construct should signal to not generate a CREATE SEQUENCE. Applies only to dialects that support sequences. Currently used only to allow PostgreSQL SERIAL to be used on a column that specifies Sequence() for usage on other backends.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
server_side_cursors: bool = False¶ deprecated; indicates if the dialect should attempt to use server side cursors by default
-
attribute
sqlalchemy.engine.default.DefaultDialect.
server_version_info: Tuple[Any, ...] | None = None¶ a tuple containing a version number for the DB backend in use.
This value is only available for supporting dialects, and is typically populated during the initial connection to the database.
-
method
sqlalchemy.engine.default.DefaultDialect.
set_connection_execution_options(connection: Connection, opts: Mapping[str, Any]) → None¶ Establish execution options for a given connection.
This is implemented by
DefaultDialect
in order to implement theConnection.execution_options.isolation_level
execution option. Dialects can intercept various execution options which may need to modify state on a particular DBAPI connection.New in version 1.4.
-
method
sqlalchemy.engine.default.DefaultDialect.
set_engine_execution_options(engine: Engine, opts: Mapping[str, Any]) → None¶ Establish execution options for a given engine.
This is implemented by
DefaultDialect
to establish event hooks for newConnection
instances created by the givenEngine
which will then invoke theDialect.set_connection_execution_options()
method for that connection.
-
method
sqlalchemy.engine.default.DefaultDialect.
set_isolation_level(dbapi_connection: DBAPIConnection, level: Literal['SERIALIZABLE', 'REPEATABLE READ', 'READ COMMITTED', 'READ UNCOMMITTED', 'AUTOCOMMIT']) → None¶ inherited from the
Dialect.set_isolation_level()
method ofDialect
Given a DBAPI connection, set its isolation level.
Note that this is a dialect-level method which is used as part of the implementation of the
Connection
andEngine
isolation level facilities; these APIs should be preferred for most typical use cases.If the dialect also implements the
Dialect.get_isolation_level_values()
method, then the given level is guaranteed to be one of the string names within that sequence, and the method will not need to anticipate a lookup failure.See also
Connection.get_isolation_level()
- view current levelConnection.default_isolation_level
- view default levelConnection.execution_options.isolation_level
- set perConnection
isolation levelcreate_engine.isolation_level
- set perEngine
isolation level
-
attribute
sqlalchemy.engine.default.DefaultDialect.
statement_compiler¶ alias of
SQLCompiler
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_alter: bool = True¶ True
if the database supportsALTER TABLE
- used only for generating foreign key constraints in certain circumstances
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_comments: bool = False¶ Indicates the dialect supports comment DDL on tables and columns.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_constraint_comments: bool = False¶ Indicates if the dialect supports comment DDL on constraints.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_default_metavalue: bool = False¶ dialect supports INSERT… VALUES (DEFAULT) syntax
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_default_values: bool = False¶ dialect supports INSERT… DEFAULT VALUES syntax
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_empty_insert: bool = True¶ dialect supports INSERT () VALUES ()
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_identity_columns: bool = False¶ target database supports IDENTITY
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_multivalues_insert: bool = False¶ Target database supports INSERT…VALUES with multiple value sets, i.e. INSERT INTO table (cols) VALUES (…), (…), (…), …
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_native_boolean: bool = False¶ Indicates if the dialect supports a native boolean construct. This will prevent
Boolean
from generating a CHECK constraint when that type is used.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_native_decimal: bool = False¶ indicates if Decimal objects are handled and returned for precision numeric types, or if floats are returned
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_native_enum: bool = False¶ Indicates if the dialect supports a native ENUM construct. This will prevent
Enum
from generating a CHECK constraint when that type is used in “native” mode.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_native_uuid: bool = False¶ indicates if Python UUID() objects are handled natively by the driver for SQL UUID datatypes.
New in version 2.0.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_sane_multi_rowcount: bool = True¶ Indicate whether the dialect properly implements rowcount for
UPDATE
andDELETE
statements when executed via executemany.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_sane_rowcount: bool = True¶ Indicate whether the dialect properly implements rowcount for
UPDATE
andDELETE
statements.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_sane_rowcount_returning¶ True if this dialect supports sane rowcount even if RETURNING is in use.
For dialects that don’t support RETURNING, this is synonymous with
supports_sane_rowcount
.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_sequences: bool = False¶ Indicates if the dialect supports CREATE SEQUENCE or similar.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_server_side_cursors: bool = False¶ indicates if the dialect supports server side cursors
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_simple_order_by_label: bool = True¶ target database supports ORDER BY <labelname>, where <labelname> refers to a label in the columns clause of the SELECT
-
attribute
sqlalchemy.engine.default.DefaultDialect.
supports_statement_cache: bool = True¶ indicates if this dialect supports caching.
All dialects that are compatible with statement caching should set this flag to True directly on each dialect class and subclass that supports it. SQLAlchemy tests that this flag is locally present on each dialect subclass before it will use statement caching. This is to provide safety for legacy or new dialects that are not yet fully tested to be compliant with SQL statement caching.
New in version 1.4.5.
See also
-
attribute
sqlalchemy.engine.default.DefaultDialect.
tuple_in_values: bool = False¶ target database supports tuple IN, i.e. (x, y) IN ((q, p), (r, z))
-
attribute
sqlalchemy.engine.default.DefaultDialect.
type_compiler: Any¶ legacy; this is a TypeCompiler class at the class level, a TypeCompiler instance at the instance level.
Refer to type_compiler_instance instead.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
type_compiler_cls¶ alias of
GenericTypeCompiler
-
attribute
sqlalchemy.engine.default.DefaultDialect.
type_compiler_instance: TypeCompiler¶ instance of a
Compiled
class used to compile SQL type objectsNew in version 2.0.
-
method
sqlalchemy.engine.default.DefaultDialect.
type_descriptor(typeobj)¶ Provide a database-specific
TypeEngine
object, given the generic object which comes from the types module.This method looks for a dictionary called
colspecs
as a class or instance-level variable, and passes on toadapt_type()
.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
update_executemany_returning: bool = False¶ dialect supports UPDATE..RETURNING with executemany.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
update_returning: bool = False¶ if the dialect supports RETURNING with UPDATE
New in version 2.0.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
update_returning_multifrom: bool = False¶ if the dialect supports RETURNING with UPDATE..FROM
New in version 2.0.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
use_insertmanyvalues: bool = False¶ if True, indicates “insertmanyvalues” functionality should be used to allow for
insert_executemany_returning
behavior, if possible.In practice, setting this to True means:
if
supports_multivalues_insert
,insert_returning
anduse_insertmanyvalues
are all True, the SQL compiler will produce an INSERT that will be interpreted by theDefaultDialect
as anExecuteStyle.INSERTMANYVALUES
execution that allows for INSERT of many rows with RETURNING by rewriting a single-row INSERT statement to have multiple VALUES clauses, also executing the statement multiple times for a series of batches when large numbers of rows are given.The parameter is False for the default dialect, and is set to True for SQLAlchemy internal dialects SQLite, MySQL/MariaDB, PostgreSQL, SQL Server. It remains at False for Oracle, which provides native “executemany with RETURNING” support and also does not support
supports_multivalues_insert
. For MySQL/MariaDB, those MySQL dialects that don’t support RETURNING will not reportinsert_executemany_returning
as True.New in version 2.0.
-
attribute
sqlalchemy.engine.default.DefaultDialect.
use_insertmanyvalues_wo_returning: bool = False¶ if True, and use_insertmanyvalues is also True, INSERT statements that don’t include RETURNING will also use “insertmanyvalues”.
New in version 2.0.
-
attribute
- class sqlalchemy.engine.Dialect¶
Define the behavior of a specific database and DB-API combination.
Any aspect of metadata definition, SQL query generation, execution, result-set handling, or anything else which varies between databases is defined under the general category of the Dialect. The Dialect acts as a factory for other database-specific object implementations including ExecutionContext, Compiled, DefaultGenerator, and TypeEngine.
Note
Third party dialects should not subclass
Dialect
directly. Instead, subclassDefaultDialect
or descendant class.Members
bind_typing, colspecs, connect(), construct_arguments, create_connect_args(), create_xid(), cte_follows_insert, dbapi, dbapi_exception_translation_map, ddl_compiler, default_isolation_level, default_metavalue_token, default_schema_name, default_sequence_base, delete_executemany_returning, delete_returning, delete_returning_multifrom, denormalize_name(), div_is_floordiv, do_begin(), do_begin_twophase(), do_close(), do_commit(), do_commit_twophase(), do_execute(), do_execute_no_params(), do_executemany(), do_ping(), do_prepare_twophase(), do_recover_twophase(), do_release_savepoint(), do_rollback(), do_rollback_to_savepoint(), do_rollback_twophase(), do_savepoint(), do_set_input_sizes(), do_terminate(), driver, engine_config_types, engine_created(), exclude_set_input_sizes, execute_sequence_format, execution_ctx_cls, favor_returning_over_lastrowid, get_async_dialect_cls(), get_check_constraints(), get_columns(), get_default_isolation_level(), get_dialect_cls(), get_dialect_pool_class(), get_driver_connection(), get_foreign_keys(), get_indexes(), get_isolation_level(), get_isolation_level_values(), get_materialized_view_names(), get_multi_check_constraints(), get_multi_columns(), get_multi_foreign_keys(), get_multi_indexes(), get_multi_pk_constraint(), get_multi_table_comment(), get_multi_table_options(), get_multi_unique_constraints(), get_pk_constraint(), get_schema_names(), get_sequence_names(), get_table_comment(), get_table_names(), get_table_options(), get_temp_table_names(), get_temp_view_names(), get_unique_constraints(), get_view_definition(), get_view_names(), has_index(), has_schema(), has_sequence(), has_table(), has_terminate, identifier_preparer, import_dbapi(), include_set_input_sizes, initialize(), inline_comments, insert_executemany_returning, insert_executemany_returning_sort_by_parameter_order, insert_returning, insertmanyvalues_implicit_sentinel, insertmanyvalues_max_parameters, insertmanyvalues_page_size, is_async, is_disconnect(), label_length, load_provisioning(), loaded_dbapi, max_identifier_length, name, normalize_name(), on_connect(), on_connect_url(), paramstyle, positional, preexecute_autoincrement_sequences, preparer, reflection_options, reset_isolation_level(), returns_native_bytes, sequences_optional, server_side_cursors, server_version_info, set_connection_execution_options(), set_engine_execution_options(), set_isolation_level(), statement_compiler, supports_alter, supports_comments, supports_constraint_comments, supports_default_metavalue, supports_default_values, supports_empty_insert, supports_identity_columns, supports_multivalues_insert, supports_native_boolean, supports_native_decimal, supports_native_enum, supports_native_uuid, supports_sane_multi_rowcount, supports_sane_rowcount, supports_sequences, supports_server_side_cursors, supports_simple_order_by_label, supports_statement_cache, tuple_in_values, type_compiler, type_compiler_cls, type_compiler_instance, type_descriptor(), update_executemany_returning, update_returning, update_returning_multifrom, use_insertmanyvalues, use_insertmanyvalues_wo_returning
Class signature
class
sqlalchemy.engine.Dialect
(sqlalchemy.event.registry.EventTarget
)-
attribute
sqlalchemy.engine.Dialect.
bind_typing = 1¶ define a means of passing typing information to the database and/or driver for bound parameters.
See
BindTyping
for values.New in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
colspecs: MutableMapping[Type[TypeEngine[Any]], Type[TypeEngine[Any]]]¶ A dictionary of TypeEngine classes from sqlalchemy.types mapped to subclasses that are specific to the dialect class. This dictionary is class-level only and is not accessed from the dialect instance itself.
-
method
sqlalchemy.engine.Dialect.
connect(*cargs: Any, **cparams: Any) → DBAPIConnection¶ Establish a connection using this dialect’s DBAPI.
The default implementation of this method is:
def connect(self, *cargs, **cparams): return self.dbapi.connect(*cargs, **cparams)
The
*cargs, **cparams
parameters are generated directly from this dialect’sDialect.create_connect_args()
method.This method may be used for dialects that need to perform programmatic per-connection steps when a new connection is procured from the DBAPI.
- Parameters:
*cargs¶ – positional parameters returned from the
Dialect.create_connect_args()
method**cparams¶ – keyword parameters returned from the
Dialect.create_connect_args()
method.
- Returns:
a DBAPI connection, typically from the PEP 249 module level
.connect()
function.
-
attribute
sqlalchemy.engine.Dialect.
construct_arguments: List[Tuple[Type[SchemaItem | ClauseElement], Mapping[str, Any]]] | None = None¶ Optional set of argument specifiers for various SQLAlchemy constructs, typically schema items.
To implement, establish as a series of tuples, as in:
construct_arguments = [ (schema.Index, { "using": False, "where": None, "ops": None }) ]
If the above construct is established on the PostgreSQL dialect, the
Index
construct will now accept the keyword argumentspostgresql_using
,postgresql_where
, nadpostgresql_ops
. Any other argument specified to the constructor ofIndex
which is prefixed withpostgresql_
will raiseArgumentError
.A dialect which does not include a
construct_arguments
member will not participate in the argument validation system. For such a dialect, any argument name is accepted by all participating constructs, within the namespace of arguments prefixed with that dialect name. The rationale here is so that third-party dialects that haven’t yet implemented this feature continue to function in the old way.See also
DialectKWArgs
- implementing base class which consumesDefaultDialect.construct_arguments
-
method
sqlalchemy.engine.Dialect.
create_connect_args(url: URL) → ConnectArgsType¶ Build DB-API compatible connection arguments.
Given a
URL
object, returns a tuple consisting of a(*args, **kwargs)
suitable to send directly to the dbapi’s connect function. The arguments are sent to theDialect.connect()
method which then runs the DBAPI-levelconnect()
function.The method typically makes use of the
URL.translate_connect_args()
method in order to generate a dictionary of options.The default implementation is:
def create_connect_args(self, url): opts = url.translate_connect_args() opts.update(url.query) return ([], opts)
- Parameters:
- Returns:
a tuple of
(*args, **kwargs)
which will be passed to theDialect.connect()
method.
See also
-
method
sqlalchemy.engine.Dialect.
create_xid() → Any¶ Create a two-phase transaction ID.
This id will be passed to do_begin_twophase(), do_rollback_twophase(), do_commit_twophase(). Its format is unspecified.
-
attribute
sqlalchemy.engine.Dialect.
cte_follows_insert: bool¶ target database, when given a CTE with an INSERT statement, needs the CTE to be below the INSERT
-
attribute
sqlalchemy.engine.Dialect.
dbapi: ModuleType | None¶ A reference to the DBAPI module object itself.
SQLAlchemy dialects import DBAPI modules using the classmethod
Dialect.import_dbapi()
. The rationale is so that any dialect module can be imported and used to generate SQL statements without the need for the actual DBAPI driver to be installed. Only when anEngine
is constructed usingcreate_engine()
does the DBAPI get imported; at that point, the creation process will assign the DBAPI module to this attribute.Dialects should therefore implement
Dialect.import_dbapi()
which will import the necessary module and return it, and then refer toself.dbapi
in dialect code in order to refer to the DBAPI module contents.Changed in version The:
Dialect.dbapi
attribute is exclusively used as the per-Dialect
-instance reference to the DBAPI module. The previous not-fully-documented.Dialect.dbapi()
classmethod is deprecated and replaced byDialect.import_dbapi()
.
-
attribute
sqlalchemy.engine.Dialect.
dbapi_exception_translation_map: Mapping[str, str] = {}¶ A dictionary of names that will contain as values the names of pep-249 exceptions (“IntegrityError”, “OperationalError”, etc) keyed to alternate class names, to support the case where a DBAPI has exception classes that aren’t named as they are referred to (e.g. IntegrityError = MyException). In the vast majority of cases this dictionary is empty.
-
attribute
sqlalchemy.engine.Dialect.
ddl_compiler: Type[DDLCompiler]¶ a
Compiled
class used to compile DDL statements
-
attribute
sqlalchemy.engine.Dialect.
default_isolation_level: IsolationLevel | None¶ the isolation that is implicitly present on new connections
-
attribute
sqlalchemy.engine.Dialect.
default_metavalue_token: str = 'DEFAULT'¶ for INSERT… VALUES (DEFAULT) syntax, the token to put in the parenthesis.
E.g. for SQLite this is the keyword “NULL”.
-
attribute
sqlalchemy.engine.Dialect.
default_schema_name: str | None¶ the name of the default schema. This value is only available for supporting dialects, and is typically populated during the initial connection to the database.
-
attribute
sqlalchemy.engine.Dialect.
default_sequence_base: int¶ the default value that will be rendered as the “START WITH” portion of a CREATE SEQUENCE DDL statement.
-
attribute
sqlalchemy.engine.Dialect.
delete_executemany_returning: bool¶ dialect supports DELETE..RETURNING with executemany.
-
attribute
sqlalchemy.engine.Dialect.
delete_returning: bool¶ if the dialect supports RETURNING with DELETE
New in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
delete_returning_multifrom: bool¶ if the dialect supports RETURNING with DELETE..FROM
New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
denormalize_name(name: str) → str¶ convert the given name to a case insensitive identifier for the backend if it is an all-lowercase name.
This method is only used if the dialect defines requires_name_normalize=True.
-
attribute
sqlalchemy.engine.Dialect.
div_is_floordiv: bool¶ target database treats the / division operator as “floor division”
-
method
sqlalchemy.engine.Dialect.
do_begin(dbapi_connection: PoolProxiedConnection) → None¶ Provide an implementation of
connection.begin()
, given a DB-API connection.The DBAPI has no dedicated “begin” method and it is expected that transactions are implicit. This hook is provided for those DBAPIs that might need additional help in this area.
- Parameters:
dbapi_connection¶ – a DBAPI connection, typically proxied within a
ConnectionFairy
.
-
method
sqlalchemy.engine.Dialect.
do_begin_twophase(connection: Connection, xid: Any) → None¶ Begin a two phase transaction on the given connection.
- Parameters:
connection¶ – a
Connection
.xid¶ – xid
-
method
sqlalchemy.engine.Dialect.
do_close(dbapi_connection: DBAPIConnection) → None¶ Provide an implementation of
connection.close()
, given a DBAPI connection.This hook is called by the
Pool
when a connection has been detached from the pool, or is being returned beyond the normal capacity of the pool.
-
method
sqlalchemy.engine.Dialect.
do_commit(dbapi_connection: PoolProxiedConnection) → None¶ Provide an implementation of
connection.commit()
, given a DB-API connection.- Parameters:
dbapi_connection¶ – a DBAPI connection, typically proxied within a
ConnectionFairy
.
-
method
sqlalchemy.engine.Dialect.
do_commit_twophase(connection: Connection, xid: Any, is_prepared: bool = True, recover: bool = False) → None¶ Commit a two phase transaction on the given connection.
- Parameters:
connection¶ – a
Connection
.xid¶ – xid
is_prepared¶ – whether or not
TwoPhaseTransaction.prepare()
was called.recover¶ – if the recover flag was passed.
-
method
sqlalchemy.engine.Dialect.
do_execute(cursor: DBAPICursor, statement: str, parameters: Sequence[Any] | Mapping[str, Any] | None, context: ExecutionContext | None = None) → None¶ Provide an implementation of
cursor.execute(statement, parameters)
.
-
method
sqlalchemy.engine.Dialect.
do_execute_no_params(cursor: DBAPICursor, statement: str, context: ExecutionContext | None = None) → None¶ Provide an implementation of
cursor.execute(statement)
.The parameter collection should not be sent.
-
method
sqlalchemy.engine.Dialect.
do_executemany(cursor: DBAPICursor, statement: str, parameters: Sequence[Sequence[Any]] | Sequence[Mapping[str, Any]], context: ExecutionContext | None = None) → None¶ Provide an implementation of
cursor.executemany(statement, parameters)
.
-
method
sqlalchemy.engine.Dialect.
do_ping(dbapi_connection: DBAPIConnection) → bool¶ ping the DBAPI connection and return True if the connection is usable.
-
method
sqlalchemy.engine.Dialect.
do_prepare_twophase(connection: Connection, xid: Any) → None¶ Prepare a two phase transaction on the given connection.
- Parameters:
connection¶ – a
Connection
.xid¶ – xid
-
method
sqlalchemy.engine.Dialect.
do_recover_twophase(connection: Connection) → List[Any]¶ Recover list of uncommitted prepared two phase transaction identifiers on the given connection.
- Parameters:
connection¶ – a
Connection
.
-
method
sqlalchemy.engine.Dialect.
do_release_savepoint(connection: Connection, name: str) → None¶ Release the named savepoint on a connection.
- Parameters:
connection¶ – a
Connection
.name¶ – savepoint name.
-
method
sqlalchemy.engine.Dialect.
do_rollback(dbapi_connection: PoolProxiedConnection) → None¶ Provide an implementation of
connection.rollback()
, given a DB-API connection.- Parameters:
dbapi_connection¶ – a DBAPI connection, typically proxied within a
ConnectionFairy
.
-
method
sqlalchemy.engine.Dialect.
do_rollback_to_savepoint(connection: Connection, name: str) → None¶ Rollback a connection to the named savepoint.
- Parameters:
connection¶ – a
Connection
.name¶ – savepoint name.
-
method
sqlalchemy.engine.Dialect.
do_rollback_twophase(connection: Connection, xid: Any, is_prepared: bool = True, recover: bool = False) → None¶ Rollback a two phase transaction on the given connection.
- Parameters:
connection¶ – a
Connection
.xid¶ – xid
is_prepared¶ – whether or not
TwoPhaseTransaction.prepare()
was called.recover¶ – if the recover flag was passed.
-
method
sqlalchemy.engine.Dialect.
do_savepoint(connection: Connection, name: str) → None¶ Create a savepoint with the given name.
- Parameters:
connection¶ – a
Connection
.name¶ – savepoint name.
-
method
sqlalchemy.engine.Dialect.
do_set_input_sizes(cursor: DBAPICursor, list_of_tuples: _GenericSetInputSizesType, context: ExecutionContext) → Any¶ invoke the cursor.setinputsizes() method with appropriate arguments
This hook is called if the
Dialect.bind_typing
attribute is set to theBindTyping.SETINPUTSIZES
value. Parameter data is passed in a list of tuples (paramname, dbtype, sqltype), whereparamname
is the key of the parameter in the statement,dbtype
is the DBAPI datatype andsqltype
is the SQLAlchemy type. The order of tuples is in the correct parameter order.New in version 1.4.
Changed in version 2.0: - setinputsizes mode is now enabled by setting
Dialect.bind_typing
toBindTyping.SETINPUTSIZES
. Dialects which accept ause_setinputsizes
parameter should set this value appropriately.
-
method
sqlalchemy.engine.Dialect.
do_terminate(dbapi_connection: DBAPIConnection) → None¶ Provide an implementation of
connection.close()
that tries as much as possible to not block, given a DBAPI connection.In the vast majority of cases this just calls .close(), however for some asyncio dialects may call upon different API features.
This hook is called by the
Pool
when a connection is being recycled or has been invalidated.New in version 1.4.41.
-
attribute
sqlalchemy.engine.Dialect.
driver: str¶ identifying name for the dialect’s DBAPI
-
attribute
sqlalchemy.engine.Dialect.
engine_config_types: Mapping[str, Any]¶ a mapping of string keys that can be in an engine config linked to type conversion functions.
-
classmethod
sqlalchemy.engine.Dialect.
engine_created(engine: Engine) → None¶ A convenience hook called before returning the final
Engine
.If the dialect returned a different class from the
get_dialect_cls()
method, then the hook is called on both classes, first on the dialect class returned by theget_dialect_cls()
method and then on the class on which the method was called.The hook should be used by dialects and/or wrappers to apply special events to the engine or its components. In particular, it allows a dialect-wrapping class to apply dialect-level events.
-
attribute
sqlalchemy.engine.Dialect.
exclude_set_input_sizes: Set[Any] | None¶ set of DBAPI type objects that should be excluded in automatic cursor.setinputsizes() calls.
This is only used if bind_typing is BindTyping.SET_INPUT_SIZES
-
attribute
sqlalchemy.engine.Dialect.
execute_sequence_format: Type[Tuple[Any, ...]] | Type[Tuple[List[Any]]]¶ either the ‘tuple’ or ‘list’ type, depending on what cursor.execute() accepts for the second argument (they vary).
-
attribute
sqlalchemy.engine.Dialect.
execution_ctx_cls: Type[ExecutionContext]¶ a
ExecutionContext
class used to handle statement execution
-
attribute
sqlalchemy.engine.Dialect.
favor_returning_over_lastrowid: bool¶ for backends that support both a lastrowid and a RETURNING insert strategy, favor RETURNING for simple single-int pk inserts.
cursor.lastrowid tends to be more performant on most backends.
-
classmethod
sqlalchemy.engine.Dialect.
get_async_dialect_cls(url: URL) → Type[Dialect]¶ Given a URL, return the
Dialect
that will be used by an async engine.By default this is an alias of
Dialect.get_dialect_cls()
and just returns the cls. It may be used if a dialect provides both a sync and async version under the same name, like thepsycopg
driver.New in version 2.
See also
-
method
sqlalchemy.engine.Dialect.
get_check_constraints(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedCheckConstraint]¶ Return information about check constraints in
table_name
.Given a string
table_name
and an optional stringschema
, return check constraint information as a list of dicts corresponding to theReflectedCheckConstraint
dictionary.This is an internal dialect method. Applications should use
Inspector.get_check_constraints()
.
-
method
sqlalchemy.engine.Dialect.
get_columns(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedColumn]¶ Return information about columns in
table_name
.Given a
Connection
, a stringtable_name
, and an optional stringschema
, return column information as a list of dictionaries corresponding to theReflectedColumn
dictionary.This is an internal dialect method. Applications should use
Inspector.get_columns()
.
-
method
sqlalchemy.engine.Dialect.
get_default_isolation_level(dbapi_conn: DBAPIConnection) → Literal['SERIALIZABLE', 'REPEATABLE READ', 'READ COMMITTED', 'READ UNCOMMITTED', 'AUTOCOMMIT']¶ Given a DBAPI connection, return its isolation level, or a default isolation level if one cannot be retrieved.
This method may only raise NotImplementedError and must not raise any other exception, as it is used implicitly upon first connect.
The method must return a value for a dialect that supports isolation level settings, as this level is what will be reverted towards when a per-connection isolation level change is made.
The method defaults to using the
Dialect.get_isolation_level()
method unless overridden by a dialect.New in version 1.3.22.
-
classmethod
sqlalchemy.engine.Dialect.
get_dialect_cls(url: URL) → Type[Dialect]¶ Given a URL, return the
Dialect
that will be used.This is a hook that allows an external plugin to provide functionality around an existing dialect, by allowing the plugin to be loaded from the url based on an entrypoint, and then the plugin returns the actual dialect to be used.
By default this just returns the cls.
-
method
sqlalchemy.engine.Dialect.
get_dialect_pool_class(url: URL) → Type[Pool]¶ return a Pool class to use for a given URL
-
method
sqlalchemy.engine.Dialect.
get_driver_connection(connection: DBAPIConnection) → Any¶ Returns the connection object as returned by the external driver package.
For normal dialects that use a DBAPI compliant driver this call will just return the
connection
passed as argument. For dialects that instead adapt a non DBAPI compliant driver, like when adapting an asyncio driver, this call will return the connection-like object as returned by the driver.New in version 1.4.24.
-
method
sqlalchemy.engine.Dialect.
get_foreign_keys(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedForeignKeyConstraint]¶ Return information about foreign_keys in
table_name
.Given a
Connection
, a stringtable_name
, and an optional stringschema
, return foreign key information as a list of dicts corresponding to theReflectedForeignKeyConstraint
dictionary.This is an internal dialect method. Applications should use
Inspector.get_foreign_keys()
.
-
method
sqlalchemy.engine.Dialect.
get_indexes(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedIndex]¶ Return information about indexes in
table_name
.Given a
Connection
, a stringtable_name
and an optional stringschema
, return index information as a list of dictionaries corresponding to theReflectedIndex
dictionary.This is an internal dialect method. Applications should use
Inspector.get_indexes()
.
-
method
sqlalchemy.engine.Dialect.
get_isolation_level(dbapi_connection: DBAPIConnection) → Literal['SERIALIZABLE', 'REPEATABLE READ', 'READ COMMITTED', 'READ UNCOMMITTED', 'AUTOCOMMIT']¶ Given a DBAPI connection, return its isolation level.
When working with a
Connection
object, the corresponding DBAPI connection may be procured using theConnection.connection
accessor.Note that this is a dialect-level method which is used as part of the implementation of the
Connection
andEngine
isolation level facilities; these APIs should be preferred for most typical use cases.See also
Connection.get_isolation_level()
- view current levelConnection.default_isolation_level
- view default levelConnection.execution_options.isolation_level
- set perConnection
isolation levelcreate_engine.isolation_level
- set perEngine
isolation level
-
method
sqlalchemy.engine.Dialect.
get_isolation_level_values(dbapi_conn: DBAPIConnection) → List[Literal['SERIALIZABLE', 'REPEATABLE READ', 'READ COMMITTED', 'READ UNCOMMITTED', 'AUTOCOMMIT']]¶ return a sequence of string isolation level names that are accepted by this dialect.
The available names should use the following conventions:
use UPPERCASE names. isolation level methods will accept lowercase names but these are normalized into UPPERCASE before being passed along to the dialect.
separate words should be separated by spaces, not underscores, e.g.
REPEATABLE READ
. isolation level names will have underscores converted to spaces before being passed along to the dialect.The names for the four standard isolation names to the extent that they are supported by the backend should be
READ UNCOMMITTED
READ COMMITTED
,REPEATABLE READ
,SERIALIZABLE
if the dialect supports an autocommit option it should be provided using the isolation level name
AUTOCOMMIT
.Other isolation modes may also be present, provided that they are named in UPPERCASE and use spaces not underscores.
This function is used so that the default dialect can check that a given isolation level parameter is valid, else raises an
ArgumentError
.A DBAPI connection is passed to the method, in the unlikely event that the dialect needs to interrogate the connection itself to determine this list, however it is expected that most backends will return a hardcoded list of values. If the dialect supports “AUTOCOMMIT”, that value should also be present in the sequence returned.
The method raises
NotImplementedError
by default. If a dialect does not implement this method, then the default dialect will not perform any checking on a given isolation level value before passing it onto theDialect.set_isolation_level()
method. This is to allow backwards-compatibility with third party dialects that may not yet be implementing this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_materialized_view_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ Return a list of all materialized view names available in the database.
This is an internal dialect method. Applications should use
Inspector.get_materialized_view_names()
.- Parameters:
schema¶ –
schema name to query, if not the default schema.
New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_multi_check_constraints(connection: Connection, *, schema: str | None = None, filter_names: Collection[str] | None = None, **kw: Any) → Iterable[Tuple[TableKey, List[ReflectedCheckConstraint]]]¶ Return information about check constraints in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_check_constraints()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_multi_columns(connection: Connection, *, schema: str | None = None, filter_names: Collection[str] | None = None, **kw: Any) → Iterable[Tuple[TableKey, List[ReflectedColumn]]]¶ Return information about columns in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_columns()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_multi_foreign_keys(connection: Connection, *, schema: str | None = None, filter_names: Collection[str] | None = None, **kw: Any) → Iterable[Tuple[TableKey, List[ReflectedForeignKeyConstraint]]]¶ Return information about foreign_keys in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_foreign_keys()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_multi_indexes(connection: Connection, *, schema: str | None = None, filter_names: Collection[str] | None = None, **kw: Any) → Iterable[Tuple[TableKey, List[ReflectedIndex]]]¶ Return information about indexes in in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_indexes()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_multi_pk_constraint(connection: Connection, *, schema: str | None = None, filter_names: Collection[str] | None = None, **kw: Any) → Iterable[Tuple[TableKey, ReflectedPrimaryKeyConstraint]]¶ Return information about primary key constraints in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_pk_constraint()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_multi_table_comment(connection: Connection, *, schema: str | None = None, filter_names: Collection[str] | None = None, **kw: Any) → Iterable[Tuple[TableKey, ReflectedTableComment]]¶ Return information about the table comment in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_table_comment()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_multi_table_options(connection: Connection, *, schema: str | None = None, filter_names: Collection[str] | None = None, **kw: Any) → Iterable[Tuple[TableKey, Dict[str, Any]]]¶ Return a dictionary of options specified when the tables in the given schema were created.
This is an internal dialect method. Applications should use
Inspector.get_multi_table_options()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_multi_unique_constraints(connection: Connection, *, schema: str | None = None, filter_names: Collection[str] | None = None, **kw: Any) → Iterable[Tuple[TableKey, List[ReflectedUniqueConstraint]]]¶ Return information about unique constraints in all tables in the given
schema
.This is an internal dialect method. Applications should use
Inspector.get_multi_unique_constraints()
.Note
The
DefaultDialect
provides a default implementation that will call the single table method for each object returned byDialect.get_table_names()
,Dialect.get_view_names()
orDialect.get_materialized_view_names()
depending on the providedkind
. Dialects that want to support a faster implementation should implement this method.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
get_pk_constraint(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → ReflectedPrimaryKeyConstraint¶ Return information about the primary key constraint on table_name`.
Given a
Connection
, a stringtable_name
, and an optional stringschema
, return primary key information as a dictionary corresponding to theReflectedPrimaryKeyConstraint
dictionary.This is an internal dialect method. Applications should use
Inspector.get_pk_constraint()
.
-
method
sqlalchemy.engine.Dialect.
get_schema_names(connection: Connection, **kw: Any) → List[str]¶ Return a list of all schema names available in the database.
This is an internal dialect method. Applications should use
Inspector.get_schema_names()
.
-
method
sqlalchemy.engine.Dialect.
get_sequence_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ Return a list of all sequence names available in the database.
This is an internal dialect method. Applications should use
Inspector.get_sequence_names()
.- Parameters:
schema¶ – schema name to query, if not the default schema.
New in version 1.4.
-
method
sqlalchemy.engine.Dialect.
get_table_comment(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → ReflectedTableComment¶ Return the “comment” for the table identified by
table_name
.Given a string
table_name
and an optional stringschema
, return table comment information as a dictionary corresponding to theReflectedTableComment
dictionary.This is an internal dialect method. Applications should use
Inspector.get_table_comment()
.- Raise:
NotImplementedError
for dialects that don’t support comments.
New in version 1.2.
-
method
sqlalchemy.engine.Dialect.
get_table_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ Return a list of table names for
schema
.This is an internal dialect method. Applications should use
Inspector.get_table_names()
.
-
method
sqlalchemy.engine.Dialect.
get_table_options(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → Dict[str, Any]¶ Return a dictionary of options specified when
table_name
was created.This is an internal dialect method. Applications should use
Inspector.get_table_options()
.
-
method
sqlalchemy.engine.Dialect.
get_temp_table_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ Return a list of temporary table names on the given connection, if supported by the underlying backend.
This is an internal dialect method. Applications should use
Inspector.get_temp_table_names()
.
-
method
sqlalchemy.engine.Dialect.
get_temp_view_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ Return a list of temporary view names on the given connection, if supported by the underlying backend.
This is an internal dialect method. Applications should use
Inspector.get_temp_view_names()
.
-
method
sqlalchemy.engine.Dialect.
get_unique_constraints(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → List[ReflectedUniqueConstraint]¶ Return information about unique constraints in
table_name
.Given a string
table_name
and an optional stringschema
, return unique constraint information as a list of dicts corresponding to theReflectedUniqueConstraint
dictionary.This is an internal dialect method. Applications should use
Inspector.get_unique_constraints()
.
-
method
sqlalchemy.engine.Dialect.
get_view_definition(connection: Connection, view_name: str, schema: str | None = None, **kw: Any) → str¶ Return plain or materialized view definition.
This is an internal dialect method. Applications should use
Inspector.get_view_definition()
.Given a
Connection
, a stringview_name
, and an optional stringschema
, return the view definition.
-
method
sqlalchemy.engine.Dialect.
get_view_names(connection: Connection, schema: str | None = None, **kw: Any) → List[str]¶ Return a list of all non-materialized view names available in the database.
This is an internal dialect method. Applications should use
Inspector.get_view_names()
.- Parameters:
schema¶ – schema name to query, if not the default schema.
-
method
sqlalchemy.engine.Dialect.
has_index(connection: Connection, table_name: str, index_name: str, schema: str | None = None, **kw: Any) → bool¶ Check the existence of a particular index name in the database.
Given a
Connection
object, a stringtable_name
and string index name, returnTrue
if an index of the given name on the given table exists,False
otherwise.The
DefaultDialect
implements this in terms of theDialect.has_table()
andDialect.get_indexes()
methods, however dialects can implement a more performant version.This is an internal dialect method. Applications should use
Inspector.has_index()
.New in version 1.4.
-
method
sqlalchemy.engine.Dialect.
has_schema(connection: Connection, schema_name: str, **kw: Any) → bool¶ Check the existence of a particular schema name in the database.
Given a
Connection
object, a stringschema_name
, returnTrue
if a schema of the given exists,False
otherwise.The
DefaultDialect
implements this by checking the presence ofschema_name
among the schemas returned byDialect.get_schema_names()
, however dialects can implement a more performant version.This is an internal dialect method. Applications should use
Inspector.has_schema()
.New in version 2.0.
-
method
sqlalchemy.engine.Dialect.
has_sequence(connection: Connection, sequence_name: str, schema: str | None = None, **kw: Any) → bool¶ Check the existence of a particular sequence in the database.
Given a
Connection
object and a string sequence_name, returnTrue
if the given sequence exists in the database,False
otherwise.This is an internal dialect method. Applications should use
Inspector.has_sequence()
.
-
method
sqlalchemy.engine.Dialect.
has_table(connection: Connection, table_name: str, schema: str | None = None, **kw: Any) → bool¶ For internal dialect use, check the existence of a particular table or view in the database.
Given a
Connection
object, a string table_name and optional schema name, return True if the given table exists in the database, False otherwise.This method serves as the underlying implementation of the public facing
Inspector.has_table()
method, and is also used internally to implement the “checkfirst” behavior for methods likeTable.create()
andMetaData.create_all()
.Note
This method is used internally by SQLAlchemy, and is published so that third-party dialects may provide an implementation. It is not the public API for checking for table presence. Please use the
Inspector.has_table()
method.Changed in version 2.0:::
Dialect.has_table()
now formally supports checking for additional table-like objects:any type of views (plain or materialized)
temporary tables of any kind
Previously, these two checks were not formally specified and different dialects would vary in their behavior. The dialect testing suite now includes tests for all of these object types, and dialects to the degree that the backing database supports views or temporary tables should seek to support locating these objects for full compliance.
-
attribute
sqlalchemy.engine.Dialect.
has_terminate: bool¶ Whether or not this dialect has a separate “terminate” implementation that does not block or require awaiting.
-
attribute
sqlalchemy.engine.Dialect.
identifier_preparer: IdentifierPreparer¶ This element will refer to an instance of
IdentifierPreparer
once aDefaultDialect
has been constructed.
-
classmethod
sqlalchemy.engine.Dialect.
import_dbapi() → module¶ Import the DBAPI module that is used by this dialect.
The Python module object returned here will be assigned as an instance variable to a constructed dialect under the name
.dbapi
.Changed in version 2.0: The
Dialect.import_dbapi()
class method is renamed from the previous method.Dialect.dbapi()
, which would be replaced at dialect instantiation time by the DBAPI module itself, thus using the same name in two different ways. If a.Dialect.dbapi()
classmethod is present on a third-party dialect, it will be used and a deprecation warning will be emitted.
-
attribute
sqlalchemy.engine.Dialect.
include_set_input_sizes: Set[Any] | None¶ set of DBAPI type objects that should be included in automatic cursor.setinputsizes() calls.
This is only used if bind_typing is BindTyping.SET_INPUT_SIZES
-
method
sqlalchemy.engine.Dialect.
initialize(connection: Connection) → None¶ Called during strategized creation of the dialect with a connection.
Allows dialects to configure options based on server version info or other properties.
The connection passed here is a SQLAlchemy Connection object, with full capabilities.
The initialize() method of the base dialect should be called via super().
Note
as of SQLAlchemy 1.4, this method is called before any
Dialect.on_connect()
hooks are called.
-
attribute
sqlalchemy.engine.Dialect.
inline_comments: bool¶ Indicates the dialect supports comment DDL that’s inline with the definition of a Table or Column. If False, this implies that ALTER must be used to set table and column comments.
-
attribute
sqlalchemy.engine.Dialect.
insert_executemany_returning: bool¶ dialect / driver / database supports some means of providing INSERT…RETURNING support when dialect.do_executemany() is used.
-
attribute
sqlalchemy.engine.Dialect.
insert_executemany_returning_sort_by_parameter_order: bool¶ dialect / driver / database supports some means of providing INSERT…RETURNING support when dialect.do_executemany() is used along with the
Insert.returning.sort_by_parameter_order
parameter being set.
-
attribute
sqlalchemy.engine.Dialect.
insert_returning: bool¶ if the dialect supports RETURNING with INSERT
New in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
insertmanyvalues_implicit_sentinel: InsertmanyvaluesSentinelOpts¶ Options indicating the database supports a form of bulk INSERT where the autoincrement integer primary key can be reliably used as an ordering for INSERTed rows.
New in version 2.0.10.
-
attribute
sqlalchemy.engine.Dialect.
insertmanyvalues_max_parameters: int¶ Alternate to insertmanyvalues_page_size, will additionally limit page size based on number of parameters total in the statement.
-
attribute
sqlalchemy.engine.Dialect.
insertmanyvalues_page_size: int¶ Number of rows to render into an individual INSERT..VALUES() statement for
ExecuteStyle.INSERTMANYVALUES
executions.The default dialect defaults this to 1000.
New in version 2.0.
See also
Connection.execution_options.insertmanyvalues_page_size
- execution option available onConnection
, statements
-
attribute
sqlalchemy.engine.Dialect.
is_async: bool¶ Whether or not this dialect is intended for asyncio use.
-
method
sqlalchemy.engine.Dialect.
is_disconnect(e: Exception, connection: PoolProxiedConnection | DBAPIConnection | None, cursor: DBAPICursor | None) → bool¶ Return True if the given DB-API error indicates an invalid connection
-
attribute
sqlalchemy.engine.Dialect.
label_length: int | None¶ optional user-defined max length for SQL labels
-
classmethod
sqlalchemy.engine.Dialect.
load_provisioning() → None¶ set up the provision.py module for this dialect.
For dialects that include a provision.py module that sets up provisioning followers, this method should initiate that process.
A typical implementation would be:
@classmethod def load_provisioning(cls): __import__("mydialect.provision")
The default method assumes a module named
provision.py
inside the owning package of the current dialect, based on the__module__
attribute:@classmethod def load_provisioning(cls): package = ".".join(cls.__module__.split(".")[0:-1]) try: __import__(package + ".provision") except ImportError: pass
New in version 1.3.14.
-
attribute
sqlalchemy.engine.Dialect.
loaded_dbapi¶ same as .dbapi, but is never None; will raise an error if no DBAPI was set up.
New in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
max_identifier_length: int¶ The maximum length of identifier names.
-
attribute
sqlalchemy.engine.Dialect.
name: str¶ identifying name for the dialect from a DBAPI-neutral point of view (i.e. ‘sqlite’)
-
method
sqlalchemy.engine.Dialect.
normalize_name(name: str) → str¶ convert the given name to lowercase if it is detected as case insensitive.
This method is only used if the dialect defines requires_name_normalize=True.
-
method
sqlalchemy.engine.Dialect.
on_connect() → Callable[[Any], Any] | None¶ return a callable which sets up a newly created DBAPI connection.
The callable should accept a single argument “conn” which is the DBAPI connection itself. The inner callable has no return value.
E.g.:
class MyDialect(default.DefaultDialect): # ... def on_connect(self): def do_on_connect(connection): connection.execute("SET SPECIAL FLAGS etc") return do_on_connect
This is used to set dialect-wide per-connection options such as isolation modes, Unicode modes, etc.
The “do_on_connect” callable is invoked by using the
PoolEvents.connect()
event hook, then unwrapping the DBAPI connection and passing it into the callable.Changed in version 1.4: the on_connect hook is no longer called twice for the first connection of a dialect. The on_connect hook is still called before the
Dialect.initialize()
method however.Changed in version 1.4.3: the on_connect hook is invoked from a new method on_connect_url that passes the URL that was used to create the connect args. Dialects can implement on_connect_url instead of on_connect if they need the URL object that was used for the connection in order to get additional context.
If None is returned, no event listener is generated.
- Returns:
a callable that accepts a single DBAPI connection as an argument, or None.
See also
Dialect.connect()
- allows the DBAPIconnect()
sequence itself to be controlled.Dialect.on_connect_url()
- supersedesDialect.on_connect()
to also receive theURL
object in context.
-
method
sqlalchemy.engine.Dialect.
on_connect_url(url: URL) → Callable[[Any], Any] | None¶ return a callable which sets up a newly created DBAPI connection.
This method is a new hook that supersedes the
Dialect.on_connect()
method when implemented by a dialect. When not implemented by a dialect, it invokes theDialect.on_connect()
method directly to maintain compatibility with existing dialects. There is no deprecation forDialect.on_connect()
expected.The callable should accept a single argument “conn” which is the DBAPI connection itself. The inner callable has no return value.
E.g.:
class MyDialect(default.DefaultDialect): # ... def on_connect_url(self, url): def do_on_connect(connection): connection.execute("SET SPECIAL FLAGS etc") return do_on_connect
This is used to set dialect-wide per-connection options such as isolation modes, Unicode modes, etc.
This method differs from
Dialect.on_connect()
in that it is passed theURL
object that’s relevant to the connect args. Normally the only way to get this is from theDialect.on_connect()
hook is to look on theEngine
itself, however this URL object may have been replaced by plugins.Note
The default implementation of
Dialect.on_connect_url()
is to invoke theDialect.on_connect()
method. Therefore if a dialect implements this method, theDialect.on_connect()
method will not be called unless the overriding dialect calls it directly from here.New in version 1.4.3: added
Dialect.on_connect_url()
which normally calls intoDialect.on_connect()
.- Parameters:
url¶ – a
URL
object representing theURL
that was passed to theDialect.create_connect_args()
method.- Returns:
a callable that accepts a single DBAPI connection as an argument, or None.
See also
-
attribute
sqlalchemy.engine.Dialect.
paramstyle: str¶ the paramstyle to be used (some DB-APIs support multiple paramstyles).
-
attribute
sqlalchemy.engine.Dialect.
positional: bool¶ True if the paramstyle for this Dialect is positional.
-
attribute
sqlalchemy.engine.Dialect.
preexecute_autoincrement_sequences: bool¶ True if ‘implicit’ primary key functions must be executed separately in order to get their value, if RETURNING is not used.
This is currently oriented towards PostgreSQL when the
implicit_returning=False
parameter is used on aTable
object.
-
attribute
sqlalchemy.engine.Dialect.
preparer: Type[IdentifierPreparer]¶ a
IdentifierPreparer
class used to quote identifiers.
-
attribute
sqlalchemy.engine.Dialect.
reflection_options: Sequence[str] = ()¶ Sequence of string names indicating keyword arguments that can be established on a
Table
object which will be passed as “reflection options” when usingTable.autoload_with
.Current example is “oracle_resolve_synonyms” in the Oracle dialect.
-
method
sqlalchemy.engine.Dialect.
reset_isolation_level(dbapi_connection: DBAPIConnection) → None¶ Given a DBAPI connection, revert its isolation to the default.
Note that this is a dialect-level method which is used as part of the implementation of the
Connection
andEngine
isolation level facilities; these APIs should be preferred for most typical use cases.See also
Connection.get_isolation_level()
- view current levelConnection.default_isolation_level
- view default levelConnection.execution_options.isolation_level
- set perConnection
isolation levelcreate_engine.isolation_level
- set perEngine
isolation level
-
attribute
sqlalchemy.engine.Dialect.
returns_native_bytes: bool¶ indicates if Python bytes() objects are returned natively by the driver for SQL “binary” datatypes.
New in version 2.0.11.
-
attribute
sqlalchemy.engine.Dialect.
sequences_optional: bool¶ If True, indicates if the
Sequence.optional
parameter on theSequence
construct should signal to not generate a CREATE SEQUENCE. Applies only to dialects that support sequences. Currently used only to allow PostgreSQL SERIAL to be used on a column that specifies Sequence() for usage on other backends.
-
attribute
sqlalchemy.engine.Dialect.
server_side_cursors: bool¶ deprecated; indicates if the dialect should attempt to use server side cursors by default
-
attribute
sqlalchemy.engine.Dialect.
server_version_info: Tuple[Any, ...] | None¶ a tuple containing a version number for the DB backend in use.
This value is only available for supporting dialects, and is typically populated during the initial connection to the database.
-
method
sqlalchemy.engine.Dialect.
set_connection_execution_options(connection: Connection, opts: CoreExecuteOptionsParameter) → None¶ Establish execution options for a given connection.
This is implemented by
DefaultDialect
in order to implement theConnection.execution_options.isolation_level
execution option. Dialects can intercept various execution options which may need to modify state on a particular DBAPI connection.New in version 1.4.
-
method
sqlalchemy.engine.Dialect.
set_engine_execution_options(engine: Engine, opts: CoreExecuteOptionsParameter) → None¶ Establish execution options for a given engine.
This is implemented by
DefaultDialect
to establish event hooks for newConnection
instances created by the givenEngine
which will then invoke theDialect.set_connection_execution_options()
method for that connection.
-
method
sqlalchemy.engine.Dialect.
set_isolation_level(dbapi_connection: DBAPIConnection, level: Literal['SERIALIZABLE', 'REPEATABLE READ', 'READ COMMITTED', 'READ UNCOMMITTED', 'AUTOCOMMIT']) → None¶ Given a DBAPI connection, set its isolation level.
Note that this is a dialect-level method which is used as part of the implementation of the
Connection
andEngine
isolation level facilities; these APIs should be preferred for most typical use cases.If the dialect also implements the
Dialect.get_isolation_level_values()
method, then the given level is guaranteed to be one of the string names within that sequence, and the method will not need to anticipate a lookup failure.See also
Connection.get_isolation_level()
- view current levelConnection.default_isolation_level
- view default levelConnection.execution_options.isolation_level
- set perConnection
isolation levelcreate_engine.isolation_level
- set perEngine
isolation level
-
attribute
sqlalchemy.engine.Dialect.
statement_compiler: Type[SQLCompiler]¶ a
Compiled
class used to compile SQL statements
-
attribute
sqlalchemy.engine.Dialect.
supports_alter: bool¶ True
if the database supportsALTER TABLE
- used only for generating foreign key constraints in certain circumstances
-
attribute
sqlalchemy.engine.Dialect.
supports_comments: bool¶ Indicates the dialect supports comment DDL on tables and columns.
-
attribute
sqlalchemy.engine.Dialect.
supports_constraint_comments: bool¶ Indicates if the dialect supports comment DDL on constraints.
-
attribute
sqlalchemy.engine.Dialect.
supports_default_metavalue: bool¶ dialect supports INSERT…(col) VALUES (DEFAULT) syntax.
Most databases support this in some way, e.g. SQLite supports it using
VALUES (NULL)
. MS SQL Server supports the syntax also however is the only included dialect where we have this disabled, as MSSQL does not support the field for the IDENTITY column, which is usually where we like to make use of the feature.
-
attribute
sqlalchemy.engine.Dialect.
supports_default_values: bool¶ dialect supports INSERT… DEFAULT VALUES syntax
-
attribute
sqlalchemy.engine.Dialect.
supports_empty_insert: bool¶ dialect supports INSERT () VALUES (), i.e. a plain INSERT with no columns in it.
This is not usually supported; an “empty” insert is typically suited using either “INSERT..DEFAULT VALUES” or “INSERT … (col) VALUES (DEFAULT)”.
-
attribute
sqlalchemy.engine.Dialect.
supports_identity_columns: bool¶ target database supports IDENTITY
-
attribute
sqlalchemy.engine.Dialect.
supports_multivalues_insert: bool¶ Target database supports INSERT…VALUES with multiple value sets, i.e. INSERT INTO table (cols) VALUES (…), (…), (…), …
-
attribute
sqlalchemy.engine.Dialect.
supports_native_boolean: bool¶ Indicates if the dialect supports a native boolean construct. This will prevent
Boolean
from generating a CHECK constraint when that type is used.
-
attribute
sqlalchemy.engine.Dialect.
supports_native_decimal: bool¶ indicates if Decimal objects are handled and returned for precision numeric types, or if floats are returned
-
attribute
sqlalchemy.engine.Dialect.
supports_native_enum: bool¶ Indicates if the dialect supports a native ENUM construct. This will prevent
Enum
from generating a CHECK constraint when that type is used in “native” mode.
-
attribute
sqlalchemy.engine.Dialect.
supports_native_uuid: bool¶ indicates if Python UUID() objects are handled natively by the driver for SQL UUID datatypes.
New in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
supports_sane_multi_rowcount: bool¶ Indicate whether the dialect properly implements rowcount for
UPDATE
andDELETE
statements when executed via executemany.
-
attribute
sqlalchemy.engine.Dialect.
supports_sane_rowcount: bool¶ Indicate whether the dialect properly implements rowcount for
UPDATE
andDELETE
statements.
-
attribute
sqlalchemy.engine.Dialect.
supports_sequences: bool¶ Indicates if the dialect supports CREATE SEQUENCE or similar.
-
attribute
sqlalchemy.engine.Dialect.
supports_server_side_cursors: bool¶ indicates if the dialect supports server side cursors
-
attribute
sqlalchemy.engine.Dialect.
supports_simple_order_by_label: bool¶ target database supports ORDER BY <labelname>, where <labelname> refers to a label in the columns clause of the SELECT
-
attribute
sqlalchemy.engine.Dialect.
supports_statement_cache: bool = True¶ indicates if this dialect supports caching.
All dialects that are compatible with statement caching should set this flag to True directly on each dialect class and subclass that supports it. SQLAlchemy tests that this flag is locally present on each dialect subclass before it will use statement caching. This is to provide safety for legacy or new dialects that are not yet fully tested to be compliant with SQL statement caching.
New in version 1.4.5.
See also
-
attribute
sqlalchemy.engine.Dialect.
tuple_in_values: bool¶ target database supports tuple IN, i.e. (x, y) IN ((q, p), (r, z))
-
attribute
sqlalchemy.engine.Dialect.
type_compiler: Any¶ legacy; this is a TypeCompiler class at the class level, a TypeCompiler instance at the instance level.
Refer to type_compiler_instance instead.
-
attribute
sqlalchemy.engine.Dialect.
type_compiler_cls: ClassVar[Type[TypeCompiler]]¶ a
Compiled
class used to compile SQL type objectsNew in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
type_compiler_instance: TypeCompiler¶ instance of a
Compiled
class used to compile SQL type objectsNew in version 2.0.
-
method
sqlalchemy.engine.Dialect.
type_descriptor(typeobj: TypeEngine[_T]) → TypeEngine[_T]¶ Transform a generic type to a dialect-specific type.
Dialect classes will usually use the
adapt_type()
function in the types module to accomplish this.The returned result is cached per dialect class so can contain no dialect-instance state.
-
attribute
sqlalchemy.engine.Dialect.
update_executemany_returning: bool¶ dialect supports UPDATE..RETURNING with executemany.
-
attribute
sqlalchemy.engine.Dialect.
update_returning: bool¶ if the dialect supports RETURNING with UPDATE
New in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
update_returning_multifrom: bool¶ if the dialect supports RETURNING with UPDATE..FROM
New in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
use_insertmanyvalues: bool¶ if True, indicates “insertmanyvalues” functionality should be used to allow for
insert_executemany_returning
behavior, if possible.In practice, setting this to True means:
if
supports_multivalues_insert
,insert_returning
anduse_insertmanyvalues
are all True, the SQL compiler will produce an INSERT that will be interpreted by theDefaultDialect
as anExecuteStyle.INSERTMANYVALUES
execution that allows for INSERT of many rows with RETURNING by rewriting a single-row INSERT statement to have multiple VALUES clauses, also executing the statement multiple times for a series of batches when large numbers of rows are given.The parameter is False for the default dialect, and is set to True for SQLAlchemy internal dialects SQLite, MySQL/MariaDB, PostgreSQL, SQL Server. It remains at False for Oracle, which provides native “executemany with RETURNING” support and also does not support
supports_multivalues_insert
. For MySQL/MariaDB, those MySQL dialects that don’t support RETURNING will not reportinsert_executemany_returning
as True.New in version 2.0.
-
attribute
sqlalchemy.engine.Dialect.
use_insertmanyvalues_wo_returning: bool¶ if True, and use_insertmanyvalues is also True, INSERT statements that don’t include RETURNING will also use “insertmanyvalues”.
New in version 2.0.
-
attribute
- class sqlalchemy.engine.default.DefaultExecutionContext¶
Members
compiled, connection, create_cursor(), current_parameters, cursor, dialect, engine, execute_style, executemany, execution_options, fetchall_for_returning(), get_current_parameters(), get_lastrowid(), get_out_parameter_values(), get_result_processor(), handle_dbapi_exception(), invoked_statement, isinsert, isupdate, lastrow_has_defaults(), no_parameters, parameters, post_exec(), postfetch_cols, pre_exec(), prefetch_cols, root_connection
Class signature
class
sqlalchemy.engine.default.DefaultExecutionContext
(sqlalchemy.engine.interfaces.ExecutionContext
)-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
compiled: Compiled | None = None¶ if passed to constructor, sqlalchemy.engine.base.Compiled object being executed
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
connection: Connection¶ Connection object which can be freely used by default value generators to execute SQL. This Connection should reference the same underlying connection/transactional resources of root_connection.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
create_cursor()¶ Return a new cursor generated from this ExecutionContext’s connection.
Some dialects may wish to change the behavior of connection.cursor(), such as postgresql which may return a PG “server side” cursor.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
current_parameters: _CoreSingleExecuteParams | None = None¶ A dictionary of parameters applied to the current row.
This attribute is only available in the context of a user-defined default generation function, e.g. as described at Context-Sensitive Default Functions. It consists of a dictionary which includes entries for each column/value pair that is to be part of the INSERT or UPDATE statement. The keys of the dictionary will be the key value of each
Column
, which is usually synonymous with the name.Note that the
DefaultExecutionContext.current_parameters
attribute does not accommodate for the “multi-values” feature of theInsert.values()
method. TheDefaultExecutionContext.get_current_parameters()
method should be preferred.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
cursor: DBAPICursor¶ DB-API cursor procured from the connection
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
dialect: Dialect¶ dialect which created this ExecutionContext.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
engine: Engine¶ engine which the Connection is associated with
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
execute_style: ExecuteStyle = 0¶ the style of DBAPI cursor method that will be used to execute a statement.
New in version 2.0.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
executemany: bool¶ True if the context has a list of more than one parameter set.
Historically this attribute links to whether
cursor.execute()
orcursor.executemany()
will be used. It also can now mean that “insertmanyvalues” may be used which indicates one or morecursor.execute()
calls.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
execution_options: _ExecuteOptions = {}¶ Execution options associated with the current statement execution
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
fetchall_for_returning(cursor)¶ For a RETURNING result, deliver cursor.fetchall() from the DBAPI cursor.
This is a dialect-specific hook for dialects that have special considerations when calling upon the rows delivered for a “RETURNING” statement. Default implementation is
cursor.fetchall()
.This hook is currently used only by the insertmanyvalues feature. Dialects that don’t set
use_insertmanyvalues=True
don’t need to consider this hook.New in version 2.0.10.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
get_current_parameters(isolate_multiinsert_groups=True)¶ Return a dictionary of parameters applied to the current row.
This method can only be used in the context of a user-defined default generation function, e.g. as described at Context-Sensitive Default Functions. When invoked, a dictionary is returned which includes entries for each column/value pair that is part of the INSERT or UPDATE statement. The keys of the dictionary will be the key value of each
Column
, which is usually synonymous with the name.- Parameters:
isolate_multiinsert_groups=True¶ – indicates that multi-valued INSERT constructs created using
Insert.values()
should be handled by returning only the subset of parameters that are local to the current column default invocation. WhenFalse
, the raw parameters of the statement are returned including the naming convention used in the case of multi-valued INSERT.
New in version 1.2: added
DefaultExecutionContext.get_current_parameters()
which provides more functionality over the existingDefaultExecutionContext.current_parameters
attribute.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
get_lastrowid()¶ return self.cursor.lastrowid, or equivalent, after an INSERT.
This may involve calling special cursor functions, issuing a new SELECT on the cursor (or a new one), or returning a stored value that was calculated within post_exec().
This function will only be called for dialects which support “implicit” primary key generation, keep preexecute_autoincrement_sequences set to False, and when no explicit id value was bound to the statement.
The function is called once for an INSERT statement that would need to return the last inserted primary key for those dialects that make use of the lastrowid concept. In these cases, it is called directly after
ExecutionContext.post_exec()
.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
get_out_parameter_values(names)¶ Return a sequence of OUT parameter values from a cursor.
For dialects that support OUT parameters, this method will be called when there is a
SQLCompiler
object which has theSQLCompiler.has_out_parameters
flag set. This flag in turn will be set to True if the statement itself hasBindParameter
objects that have the.isoutparam
flag set which are consumed by theSQLCompiler.visit_bindparam()
method. If the dialect compiler producesBindParameter
objects with.isoutparam
set which are not handled bySQLCompiler.visit_bindparam()
, it should set this flag explicitly.The list of names that were rendered for each bound parameter is passed to the method. The method should then return a sequence of values corresponding to the list of parameter objects. Unlike in previous SQLAlchemy versions, the values can be the raw values from the DBAPI; the execution context will apply the appropriate type handler based on what’s present in self.compiled.binds and update the values. The processed dictionary will then be made available via the
.out_parameters
collection on the result object. Note that SQLAlchemy 1.4 has multiple kinds of result object as part of the 2.0 transition.New in version 1.4: - added
ExecutionContext.get_out_parameter_values()
, which is invoked automatically by theDefaultExecutionContext
when there areBindParameter
objects with the.isoutparam
flag set. This replaces the practice of setting out parameters within the now-removedget_result_proxy()
method.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
get_result_processor(type_, colname, coltype)¶ Return a ‘result processor’ for a given type as present in cursor.description.
This has a default implementation that dialects can override for context-sensitive result type handling.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
handle_dbapi_exception(e)¶ Receive a DBAPI exception which occurred upon execute, result fetch, etc.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
invoked_statement: Executable | None = None¶ The Executable statement object that was given in the first place.
This should be structurally equivalent to compiled.statement, but not necessarily the same object as in a caching scenario the compiled form will have been extracted from the cache.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
isinsert: bool = False¶ True if the statement is an INSERT.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
isupdate: bool = False¶ True if the statement is an UPDATE.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
lastrow_has_defaults()¶ Return True if the last INSERT or UPDATE row contained inlined or database-side defaults.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
no_parameters: bool¶ True if the execution style does not use parameters
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
parameters: _DBAPIMultiExecuteParams¶ bind parameters passed to the execute() or exec_driver_sql() methods.
These are always stored as a list of parameter entries. A single-element list corresponds to a
cursor.execute()
call and a multiple-element list corresponds tocursor.executemany()
, except in the case ofExecuteStyle.INSERTMANYVALUES
which will usecursor.execute()
one or more times.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
post_exec()¶ Called after the execution of a compiled statement.
If a compiled statement was passed to this ExecutionContext, the last_insert_ids, last_inserted_params, etc. datamembers should be available after this method completes.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
postfetch_cols: util.generic_fn_descriptor[Sequence[Column[Any]] | None]¶ a list of Column objects for which a server-side default or inline SQL expression value was fired off. Applies to inserts and updates.
-
method
sqlalchemy.engine.default.DefaultExecutionContext.
pre_exec()¶ Called before an execution of a compiled statement.
If a compiled statement was passed to this ExecutionContext, the statement and parameters datamembers must be initialized after this statement is complete.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
prefetch_cols: util.generic_fn_descriptor[Sequence[Column[Any]] | None]¶ a list of Column objects for which a client-side default was fired off. Applies to inserts and updates.
-
attribute
sqlalchemy.engine.default.DefaultExecutionContext.
root_connection: Connection¶ Connection object which is the source of this ExecutionContext.
-
attribute
- class sqlalchemy.engine.ExecutionContext¶
Members
compiled, connection, create_cursor(), cursor, dialect, engine, execute_style, executemany, execution_options, fetchall_for_returning(), fire_sequence(), get_out_parameter_values(), get_rowcount(), handle_dbapi_exception(), invoked_statement, isinsert, isupdate, lastrow_has_defaults(), no_parameters, parameters, post_exec(), postfetch_cols, pre_exec(), prefetch_cols, root_connection, statement
A messenger object for a Dialect that corresponds to a single execution.
-
attribute
sqlalchemy.engine.ExecutionContext.
compiled: Compiled | None¶ if passed to constructor, sqlalchemy.engine.base.Compiled object being executed
-
attribute
sqlalchemy.engine.ExecutionContext.
connection: Connection¶ Connection object which can be freely used by default value generators to execute SQL. This Connection should reference the same underlying connection/transactional resources of root_connection.
-
method
sqlalchemy.engine.ExecutionContext.
create_cursor() → DBAPICursor¶ Return a new cursor generated from this ExecutionContext’s connection.
Some dialects may wish to change the behavior of connection.cursor(), such as postgresql which may return a PG “server side” cursor.
-
attribute
sqlalchemy.engine.ExecutionContext.
cursor: DBAPICursor¶ DB-API cursor procured from the connection
-
attribute
sqlalchemy.engine.ExecutionContext.
dialect: Dialect¶ dialect which created this ExecutionContext.
-
attribute
sqlalchemy.engine.ExecutionContext.
engine: Engine¶ engine which the Connection is associated with
-
attribute
sqlalchemy.engine.ExecutionContext.
execute_style: ExecuteStyle¶ the style of DBAPI cursor method that will be used to execute a statement.
New in version 2.0.
-
attribute
sqlalchemy.engine.ExecutionContext.
executemany: bool¶ True if the context has a list of more than one parameter set.
Historically this attribute links to whether
cursor.execute()
orcursor.executemany()
will be used. It also can now mean that “insertmanyvalues” may be used which indicates one or morecursor.execute()
calls.
-
attribute
sqlalchemy.engine.ExecutionContext.
execution_options: _ExecuteOptions¶ Execution options associated with the current statement execution
-
method
sqlalchemy.engine.ExecutionContext.
fetchall_for_returning(cursor: DBAPICursor) → Sequence[Any]¶ For a RETURNING result, deliver cursor.fetchall() from the DBAPI cursor.
This is a dialect-specific hook for dialects that have special considerations when calling upon the rows delivered for a “RETURNING” statement. Default implementation is
cursor.fetchall()
.This hook is currently used only by the insertmanyvalues feature. Dialects that don’t set
use_insertmanyvalues=True
don’t need to consider this hook.New in version 2.0.10.
-
method
sqlalchemy.engine.ExecutionContext.
fire_sequence(seq: Sequence_SchemaItem, type_: Integer) → int¶ given a
Sequence
, invoke it and return the next int value
-
method
sqlalchemy.engine.ExecutionContext.
get_out_parameter_values(out_param_names: Sequence[str]) → Sequence[Any]¶ Return a sequence of OUT parameter values from a cursor.
For dialects that support OUT parameters, this method will be called when there is a
SQLCompiler
object which has theSQLCompiler.has_out_parameters
flag set. This flag in turn will be set to True if the statement itself hasBindParameter
objects that have the.isoutparam
flag set which are consumed by theSQLCompiler.visit_bindparam()
method. If the dialect compiler producesBindParameter
objects with.isoutparam
set which are not handled bySQLCompiler.visit_bindparam()
, it should set this flag explicitly.The list of names that were rendered for each bound parameter is passed to the method. The method should then return a sequence of values corresponding to the list of parameter objects. Unlike in previous SQLAlchemy versions, the values can be the raw values from the DBAPI; the execution context will apply the appropriate type handler based on what’s present in self.compiled.binds and update the values. The processed dictionary will then be made available via the
.out_parameters
collection on the result object. Note that SQLAlchemy 1.4 has multiple kinds of result object as part of the 2.0 transition.New in version 1.4: - added
ExecutionContext.get_out_parameter_values()
, which is invoked automatically by theDefaultExecutionContext
when there areBindParameter
objects with the.isoutparam
flag set. This replaces the practice of setting out parameters within the now-removedget_result_proxy()
method.
-
method
sqlalchemy.engine.ExecutionContext.
get_rowcount() → int | None¶ Return the DBAPI
cursor.rowcount
value, or in some cases an interpreted value.See
CursorResult.rowcount
for details on this.
-
method
sqlalchemy.engine.ExecutionContext.
handle_dbapi_exception(e: BaseException) → None¶ Receive a DBAPI exception which occurred upon execute, result fetch, etc.
-
attribute
sqlalchemy.engine.ExecutionContext.
invoked_statement: Executable | None¶ The Executable statement object that was given in the first place.
This should be structurally equivalent to compiled.statement, but not necessarily the same object as in a caching scenario the compiled form will have been extracted from the cache.
-
attribute
sqlalchemy.engine.ExecutionContext.
isinsert: bool¶ True if the statement is an INSERT.
-
attribute
sqlalchemy.engine.ExecutionContext.
isupdate: bool¶ True if the statement is an UPDATE.
-
method
sqlalchemy.engine.ExecutionContext.
lastrow_has_defaults() → bool¶ Return True if the last INSERT or UPDATE row contained inlined or database-side defaults.
-
attribute
sqlalchemy.engine.ExecutionContext.
no_parameters: bool¶ True if the execution style does not use parameters
-
attribute
sqlalchemy.engine.ExecutionContext.
parameters: _AnyMultiExecuteParams¶ bind parameters passed to the execute() or exec_driver_sql() methods.
These are always stored as a list of parameter entries. A single-element list corresponds to a
cursor.execute()
call and a multiple-element list corresponds tocursor.executemany()
, except in the case ofExecuteStyle.INSERTMANYVALUES
which will usecursor.execute()
one or more times.
-
method
sqlalchemy.engine.ExecutionContext.
post_exec() → None¶ Called after the execution of a compiled statement.
If a compiled statement was passed to this ExecutionContext, the last_insert_ids, last_inserted_params, etc. datamembers should be available after this method completes.
-
attribute
sqlalchemy.engine.ExecutionContext.
postfetch_cols: util.generic_fn_descriptor[Sequence[Column[Any]] | None]¶ a list of Column objects for which a server-side default or inline SQL expression value was fired off. Applies to inserts and updates.
-
method
sqlalchemy.engine.ExecutionContext.
pre_exec() → None¶ Called before an execution of a compiled statement.
If a compiled statement was passed to this ExecutionContext, the statement and parameters datamembers must be initialized after this statement is complete.
-
attribute
sqlalchemy.engine.ExecutionContext.
prefetch_cols: util.generic_fn_descriptor[Sequence[Column[Any]] | None]¶ a list of Column objects for which a client-side default was fired off. Applies to inserts and updates.
-
attribute
sqlalchemy.engine.ExecutionContext.
root_connection: Connection¶ Connection object which is the source of this ExecutionContext.
-
attribute
sqlalchemy.engine.ExecutionContext.
statement: str¶ string version of the statement to be executed. Is either passed to the constructor, or must be created from the sql.Compiled object by the time pre_exec() has completed.
-
attribute
- class sqlalchemy.sql.compiler.ExpandedState¶
represents state to use when producing “expanded” and “post compile” bound parameters for a statement.
“expanded” parameters are parameters that are generated at statement execution time to suit a number of parameters passed, the most prominent example being the individual elements inside of an IN expression.
“post compile” parameters are parameters where the SQL literal value will be rendered into the SQL statement at execution time, rather than being passed as separate parameters to the driver.