관리-도구
편집 파일: interfaces.cpython-37.pyc
B ��4]�� � @ s| d Z ddlmZ ddlmZ ddlmZ G dd� de�ZG dd� de�ZG d d � d e�Z G dd� de�Z G d d� de�ZdS )z1Define core interfaces used by the engine system.� )�util)�Compiled)�TypeCompilerc @ s� e Zd ZdZdZdd� Zedd� �Zdd� Zd d � Z dcdd �Z e�dd�dddd��Z dedd�Zdfdd�Zdgdd�Zdhdd�Zdidd�Zdjdd�Zdkdd�Zdld d!�Zdmd"d#�Zdnd$d%�Zdod&d'�Zd(d)� Zd*d+� Zdpd,d-�Zdqd.d/�Zd0d1� Zd2d3� Zd4d5� Zd6d7� Z d8d9� Z!d:d;� Z"d<d=� Z#d>d?� Z$d@dA� Z%dBdC� Z&dDdE� Z'dFdG� Z(drdIdJ�Z)dsdKdL�Z*dMdN� Z+dtdOdP�Z,dudQdR�Z-dvdSdT�Z.dUdV� Z/dWdX� Z0dYdZ� Z1d[d\� Z2d]d^� Z3ed_d`� �Z4edadb� �Z5dS )w�Dialecta� 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. All Dialects implement the following attributes: name identifying name for the dialect from a DBAPI-neutral point of view (i.e. 'sqlite') driver identifying name for the dialect's DBAPI positional True if the paramstyle for this Dialect is positional. paramstyle the paramstyle to be used (some DB-APIs support multiple paramstyles). convert_unicode True if Unicode conversion should be applied to all ``str`` types. encoding type of encoding to use for unicode, usually defaults to 'utf-8'. statement_compiler a :class:`.Compiled` class used to compile SQL statements ddl_compiler a :class:`.Compiled` class used to compile DDL statements server_version_info 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. default_schema_name 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. execution_ctx_cls a :class:`.ExecutionContext` class used to handle statement execution execute_sequence_format either the 'tuple' or 'list' type, depending on what cursor.execute() accepts for the second argument (they vary). preparer a :class:`~sqlalchemy.sql.compiler.IdentifierPreparer` class used to quote identifiers. supports_alter ``True`` if the database supports ``ALTER TABLE``. max_identifier_length The maximum length of identifier names. supports_unicode_statements Indicate whether the DB-API can receive SQL statements as Python unicode strings supports_unicode_binds Indicate whether the DB-API can receive string bind parameters as Python unicode strings supports_sane_rowcount Indicate whether the dialect properly implements rowcount for ``UPDATE`` and ``DELETE`` statements. supports_sane_multi_rowcount Indicate whether the dialect properly implements rowcount for ``UPDATE`` and ``DELETE`` statements when executed via executemany. preexecute_autoincrement_sequences True if 'implicit' primary key functions must be executed separately in order to get their value. This is currently oriented towards PostgreSQL. implicit_returning use RETURNING or equivalent during INSERT execution in order to load newly generated primary keys and other column defaults in one execution, which are then available via inserted_primary_key. If an insert statement has returning() specified explicitly, the "implicit" functionality is not used and inserted_primary_key will not be available. colspecs 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. supports_default_values Indicates if the construct ``INSERT INTO tablename DEFAULT VALUES`` is supported supports_sequences Indicates if the dialect supports CREATE SEQUENCE or similar. sequences_optional If True, indicates if the "optional" flag on the Sequence() 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. supports_native_enum Indicates if the dialect supports a native ENUM construct. This will prevent types.Enum from generating a CHECK constraint when that type is used. supports_native_boolean Indicates if the dialect supports a native boolean construct. This will prevent types.Boolean from generating a CHECK constraint when that type is used. dbapi_exception_translation_map 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. .. versionadded:: 1.0.5 Fc C s t � �dS )z�Build DB-API compatible connection arguments. Given a :class:`~sqlalchemy.engine.url.URL` object, returns a tuple consisting of a `*args`/`**kwargs` suitable to send directly to the dbapi's connect function. N)�NotImplementedError)�self�url� r �O/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/engine/interfaces.py�create_connect_args� s zDialect.create_connect_argsc C s t � �dS )a4 Transform a generic type to a dialect-specific type. Dialect classes will usually use the :func:`.types.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. N)r )�cls�typeobjr r r �type_descriptor� s zDialect.type_descriptorc C s dS )a� 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(). Nr )r � connectionr r r � initialize� s zDialect.initializec C s t � �dS )ar Load table description from the database. Given a :class:`.Connection` and a :class:`~sqlalchemy.schema.Table` object, reflect its columns and properties from the database. The implementation of this method is provided by :meth:`.DefaultDialect.reflecttable`, which makes use of :class:`.Inspector` to retrieve column information. Dialects should **not** seek to implement this method, and should instead implement individual schema inspection operations such as :meth:`.Dialect.get_columns`, :meth:`.Dialect.get_pk_constraint`, etc. N)r )r r �tableZinclude_columnsZexclude_columnsZresolve_fksr r r �reflecttable� s zDialect.reflecttableNc K s t � �dS )a Return information about columns in `table_name`. Given a :class:`.Connection`, a string `table_name`, and an optional string `schema`, return column information as a list of dictionaries with these keys: name the column's name type [sqlalchemy.types#TypeEngine] nullable boolean default the column's default value autoincrement boolean sequence a dictionary of the form {'name' : str, 'start' :int, 'increment': int, 'minvalue': int, 'maxvalue': int, 'nominvalue': bool, 'nomaxvalue': bool, 'cycle': bool, 'cache': int, 'order': bool} Additional column attributes may be present. N)r )r r � table_name�schema�kwr r r �get_columns� s zDialect.get_columnsz0.8z�The :meth:`.Dialect.get_primary_keys` method is deprecated and will be removed in a future release. Please refer to the :meth:`.Dialect.get_pk_constraint` method. c K s t � �dS )z@Return information about primary keys in `table_name`. N)r )r r r r r r r r �get_primary_keys� s zDialect.get_primary_keysc K s t � �dS )a� Return information about the primary key constraint on table_name`. Given a :class:`.Connection`, a string `table_name`, and an optional string `schema`, return primary key information as a dictionary with these keys: constrained_columns a list of column names that make up the primary key name optional name of the primary key constraint. N)r )r r r r r r r r �get_pk_constraint s zDialect.get_pk_constraintc K s t � �dS )a� Return information about foreign_keys in `table_name`. Given a :class:`.Connection`, a string `table_name`, and an optional string `schema`, return foreign key information as a list of dicts with these keys: name the constraint's name constrained_columns a list of column names that make up the foreign key referred_schema the name of the referred schema referred_table the name of the referred table referred_columns a list of column names in the referred table that correspond to constrained_columns N)r )r r r r r r r r �get_foreign_keys s zDialect.get_foreign_keysc K s t � �dS )z*Return a list of table names for `schema`.N)r )r r r r r r r �get_table_names6 s zDialect.get_table_namesc K s t � �dS )zyReturn a list of temporary table names on the given connection, if supported by the underlying backend. N)r )r r r r r r r �get_temp_table_names; s zDialect.get_temp_table_namesc K s t � �dS )z�Return a list of all view names available in the database. schema: Optional, retrieve names from a non-default schema. N)r )r r r r r r r �get_view_namesC s zDialect.get_view_namesc K s t � �dS )zxReturn a list of temporary view names on the given connection, if supported by the underlying backend. N)r )r r r r r r r �get_temp_view_namesL s zDialect.get_temp_view_namesc K s t � �dS )z�Return view definition. Given a :class:`.Connection`, a string `view_name`, and an optional string `schema`, return the view definition. N)r )r r Z view_namer r r r r �get_view_definitionT s zDialect.get_view_definitionc K s t � �dS )au Return information about indexes in `table_name`. Given a :class:`.Connection`, a string `table_name` and an optional string `schema`, return index information as a list of dictionaries with these keys: name the index's name column_names list of column names in order unique boolean N)r )r r r r r r r r �get_indexes^ s zDialect.get_indexesc K s t � �dS )a� Return information about unique constraints in `table_name`. Given a string `table_name` and an optional string `schema`, return unique constraint information as a list of dicts with these keys: name the unique constraint's name column_names list of column names in order \**kw other options passed to the dialect's get_unique_constraints() method. .. versionadded:: 0.9.0 N)r )r r r r r r r r �get_unique_constraintsq s zDialect.get_unique_constraintsc K s t � �dS )a� Return information about check constraints in `table_name`. Given a string `table_name` and an optional string `schema`, return check constraint information as a list of dicts with these keys: name the check constraint's name sqltext the check constraint's SQL expression \**kw other options passed to the dialect's get_check_constraints() method. .. versionadded:: 1.1.0 N)r )r r r r r r r r �get_check_constraints� s zDialect.get_check_constraintsc K s t � �dS )a| Return the "comment" for the table identified by `table_name`. Given a string `table_name` and an optional string `schema`, return table comment information as a dictionary with this key: text text of the comment Raises ``NotImplementedError`` for dialects that don't support comments. .. versionadded:: 1.2 N)r )r r r r r r r r �get_table_comment� s zDialect.get_table_commentc C s t � �dS )z�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. N)r )r �namer r r �normalize_name� s zDialect.normalize_namec C s t � �dS )z�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. N)r )r r# r r r �denormalize_name� s zDialect.denormalize_namec C s t � �dS )a Check the existence of a particular table in the database. Given a :class:`.Connection` object and a string `table_name`, return True if the given table (possibly within the specified `schema`) exists in the database, False otherwise. N)r )r r r r r r r � has_table� s zDialect.has_tablec C s t � �dS )z�Check the existence of a particular sequence in the database. Given a :class:`.Connection` object and a string `sequence_name`, return True if the given sequence exists in the database, False otherwise. N)r )r r Z sequence_namer r r r �has_sequence� s zDialect.has_sequencec C s t � �dS )z�Retrieve the server version info from the given connection. This is used by the default implementation to populate the "server_version_info" attribute and is called exactly once upon first connect. N)r )r r r r r �_get_server_version_info� s z Dialect._get_server_version_infoc C s t � �dS )a Return the string name of the currently selected schema from the given connection. This is used by the default implementation to populate the "default_schema_name" attribute and is called exactly once upon first connect. N)r )r r r r r �_get_default_schema_name� s z Dialect._get_default_schema_namec C s t � �dS )a/ 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. Note that :meth:`.Dialect.do_begin` is not called unless a :class:`.Transaction` object is in use. The :meth:`.Dialect.do_autocommit` hook is provided for DBAPIs that need some extra commands emitted after a commit in order to enter the next transaction, when the SQLAlchemy :class:`.Connection` is used in its default "autocommit" mode. :param dbapi_connection: a DBAPI connection, typically proxied within a :class:`.ConnectionFairy`. N)r )r �dbapi_connectionr r r �do_begin� s zDialect.do_beginc C s t � �dS )z�Provide an implementation of ``connection.rollback()``, given a DB-API connection. :param dbapi_connection: a DBAPI connection, typically proxied within a :class:`.ConnectionFairy`. N)r )r r* r r r �do_rollback s zDialect.do_rollbackc C s t � �dS )z�Provide an implementation of ``connection.commit()``, given a DB-API connection. :param dbapi_connection: a DBAPI connection, typically proxied within a :class:`.ConnectionFairy`. N)r )r r* r r r � do_commit s zDialect.do_commitc C s t � �dS )a Provide an implementation of ``connection.close()``, given a DBAPI connection. This hook is called by the :class:`.Pool` when a connection has been detached from the pool, or is being returned beyond the normal capacity of the pool. N)r )r r* r r r �do_close s zDialect.do_closec C s t � �dS )z�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. N)r )r r r r � create_xid* s zDialect.create_xidc C s t � �dS )z�Create a savepoint with the given name. :param connection: a :class:`.Connection`. :param name: savepoint name. N)r )r r r# r r r �do_savepoint4 s zDialect.do_savepointc C s t � �dS )z�Rollback a connection to the named savepoint. :param connection: a :class:`.Connection`. :param name: savepoint name. N)r )r r r# r r r �do_rollback_to_savepoint> s z Dialect.do_rollback_to_savepointc C s t � �dS )z�Release the named savepoint on a connection. :param connection: a :class:`.Connection`. :param name: savepoint name. N)r )r r r# r r r �do_release_savepointH s zDialect.do_release_savepointc C s t � �dS )z�Begin a two phase transaction on the given connection. :param connection: a :class:`.Connection`. :param xid: xid N)r )r r �xidr r r �do_begin_twophaseQ s zDialect.do_begin_twophasec C s t � �dS )z�Prepare a two phase transaction on the given connection. :param connection: a :class:`.Connection`. :param xid: xid N)r )r r r3 r r r �do_prepare_twophase[ s zDialect.do_prepare_twophaseTc C s t � �dS )a, Rollback a two phase transaction on the given connection. :param connection: a :class:`.Connection`. :param xid: xid :param is_prepared: whether or not :meth:`.TwoPhaseTransaction.prepare` was called. :param recover: if the recover flag was passed. N)r )r r r3 �is_prepared�recoverr r r �do_rollback_twophasee s zDialect.do_rollback_twophasec C s t � �dS )a+ Commit a two phase transaction on the given connection. :param connection: a :class:`.Connection`. :param xid: xid :param is_prepared: whether or not :meth:`.TwoPhaseTransaction.prepare` was called. :param recover: if the recover flag was passed. N)r )r r r3 r6 r7 r r r �do_commit_twophaset s zDialect.do_commit_twophasec C s t � �dS )z�Recover list of uncommitted prepared two phase transaction identifiers on the given connection. :param connection: a :class:`.Connection`. N)r )r r r r r �do_recover_twophase� s zDialect.do_recover_twophasec C s t � �dS )zSProvide an implementation of ``cursor.executemany(statement, parameters)``.N)r )r �cursor� statement� parameters�contextr r r �do_executemany� s zDialect.do_executemanyc C s t � �dS )zOProvide an implementation of ``cursor.execute(statement, parameters)``.N)r )r r; r<