ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ 4]c@sdZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Zdd lmZdd lmZdd lmZddl mZddl mZddl mZdd l mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl mZddl m Z ddl m!Z!ddl m"Z"ddl m#Z#ddlm$Z$d fZ%d!fZ&d"fZ'd#fZ(d$fZ)d%fZ*e+d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddgZ,dej-fdYZ-dej.fdYZ/dej0fdYZ1dej2fdYZ2e2Z3de4fdYZ5de5ej6fdYZ7de5ej6fdYZ8de5ej6fdYZ9dej:fdYZ;de4fdYZ<de<ej=fdYZ>de<ej?fdYZ@dejAfdYZBdeBfdYZCdej?fdYZDdejEejFfdYZEdejFfdYZGdejHfdYZIdej:fdYZJdej:fdYZKdej:fdYZLdej:fdYZMdej:fdYZNe7ZOe1ZPe-ZQe/ZRe2ZSe8ZTe9ZUe;ZVe"ZWeDZXe#ZYe ZZeZ[eZ\eZ]eEZ^eGZ_eJZ`eKZaeLZbeMZceNZdied6ed 6e!d 6e/d 6e#d 6e d 6ed6ed6e"d6eDd6ed6ed6ed6ed6e9d6e;d6ed6e2d6e8d6ed6eEd6eJd6e-d6eGd6eId 6eBd!6eKd"6eLd#6eMd$6eNd%6Zed&ejffd'YZgd(ejhfd)YZid*ejjfd+YZkd,ekfd-YZld.ejmfd/YZnd0ejofd1YZpd2Zqd3Zrd4Zsd5Ztd6Zud7ejvfd8YZwdS(9s Y .. dialect:: mssql :name: Microsoft SQL Server .. _mssql_identity: Auto Increment Behavior / IDENTITY Columns ------------------------------------------ SQL Server provides so-called "auto incrementing" behavior using the ``IDENTITY`` construct, which can be placed on any single integer column in a table. SQLAlchemy considers ``IDENTITY`` within its default "autoincrement" behavior for an integer primary key column, described at :paramref:`.Column.autoincrement`. This means that by default, the first integer primary key column in a :class:`.Table` will be considered to be the identity column and will generate DDL as such:: from sqlalchemy import Table, MetaData, Column, Integer m = MetaData() t = Table('t', m, Column('id', Integer, primary_key=True), Column('x', Integer)) m.create_all(engine) The above example will generate DDL as: .. sourcecode:: sql CREATE TABLE t ( id INTEGER NOT NULL IDENTITY(1,1), x INTEGER NULL, PRIMARY KEY (id) ) For the case where this default generation of ``IDENTITY`` is not desired, specify ``False`` for the :paramref:`.Column.autoincrement` flag, on the first integer primary key column:: m = MetaData() t = Table('t', m, Column('id', Integer, primary_key=True, autoincrement=False), Column('x', Integer)) m.create_all(engine) To add the ``IDENTITY`` keyword to a non-primary key column, specify ``True`` for the :paramref:`.Column.autoincrement` flag on the desired :class:`.Column` object, and ensure that :paramref:`.Column.autoincrement` is set to ``False`` on any integer primary key column:: m = MetaData() t = Table('t', m, Column('id', Integer, primary_key=True, autoincrement=False), Column('x', Integer, autoincrement=True)) m.create_all(engine) .. versionchanged:: 1.3 Added ``mssql_identity_start`` and ``mssql_identity_increment`` parameters to :class:`.Column`. These replace the use of the :class:`.Sequence` object in order to specify these values. .. deprecated:: 1.3 The use of :class:`.Sequence` to specify IDENTITY characteristics is deprecated and will be removed in a future release. Please use the ``mssql_identity_start`` and ``mssql_identity_increment`` parameters documented at :ref:`mssql_identity`. .. note:: There can only be one IDENTITY column on the table. When using ``autoincrement=True`` to enable the IDENTITY keyword, SQLAlchemy does not guard against multiple columns specifying the option simultaneously. The SQL Server database will instead reject the ``CREATE TABLE`` statement. .. note:: An INSERT statement which attempts to provide a value for a column that is marked with IDENTITY will be rejected by SQL Server. In order for the value to be accepted, a session-level option "SET IDENTITY_INSERT" must be enabled. The SQLAlchemy SQL Server dialect will perform this operation automatically when using a core :class:`.Insert` construct; if the execution specifies a value for the IDENTITY column, the "IDENTITY_INSERT" option will be enabled for the span of that statement's invocation.However, this scenario is not high performing and should not be relied upon for normal use. If a table doesn't actually require IDENTITY behavior in its integer primary key column, the keyword should be disabled when creating the table by ensuring that ``autoincrement=False`` is set. Controlling "Start" and "Increment" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Specific control over the "start" and "increment" values for the ``IDENTITY`` generator are provided using the ``mssql_identity_start`` and ``mssql_identity_increment`` parameters passed to the :class:`.Column` object:: from sqlalchemy import Table, Integer, Column test = Table( 'test', metadata, Column( 'id', Integer, primary_key=True, mssql_identity_start=100, mssql_identity_increment=10 ), Column('name', String(20)) ) The CREATE TABLE for the above :class:`.Table` object would be: .. sourcecode:: sql CREATE TABLE test ( id INTEGER NOT NULL IDENTITY(100,10) PRIMARY KEY, name VARCHAR(20) NULL, ) .. versionchanged:: 1.3 The ``mssql_identity_start`` and ``mssql_identity_increment`` parameters are now used to affect the ``IDENTITY`` generator for a :class:`.Column` under SQL Server. Previously, the :class:`.Sequence` object was used. As SQL Server now supports real sequences as a separate construct, :class:`.Sequence` will be functional in the normal way in a future SQLAlchemy version. INSERT behavior ^^^^^^^^^^^^^^^^ Handling of the ``IDENTITY`` column at INSERT time involves two key techniques. The most common is being able to fetch the "last inserted value" for a given ``IDENTITY`` column, a process which SQLAlchemy performs implicitly in many cases, most importantly within the ORM. The process for fetching this value has several variants: * In the vast majority of cases, RETURNING is used in conjunction with INSERT statements on SQL Server in order to get newly generated primary key values: .. sourcecode:: sql INSERT INTO t (x) OUTPUT inserted.id VALUES (?) * When RETURNING is not available or has been disabled via ``implicit_returning=False``, either the ``scope_identity()`` function or the ``@@identity`` variable is used; behavior varies by backend: * when using PyODBC, the phrase ``; select scope_identity()`` will be appended to the end of the INSERT statement; a second result set will be fetched in order to receive the value. Given a table as:: t = Table('t', m, Column('id', Integer, primary_key=True), Column('x', Integer), implicit_returning=False) an INSERT will look like: .. sourcecode:: sql INSERT INTO t (x) VALUES (?); select scope_identity() * Other dialects such as pymssql will call upon ``SELECT scope_identity() AS lastrowid`` subsequent to an INSERT statement. If the flag ``use_scope_identity=False`` is passed to :func:`.create_engine`, the statement ``SELECT @@identity AS lastrowid`` is used instead. A table that contains an ``IDENTITY`` column will prohibit an INSERT statement that refers to the identity column explicitly. The SQLAlchemy dialect will detect when an INSERT construct, created using a core :func:`.insert` construct (not a plain string SQL), refers to the identity column, and in this case will emit ``SET IDENTITY_INSERT ON`` prior to the insert statement proceeding, and ``SET IDENTITY_INSERT OFF`` subsequent to the execution. Given this example:: m = MetaData() t = Table('t', m, Column('id', Integer, primary_key=True), Column('x', Integer)) m.create_all(engine) engine.execute(t.insert(), {'id': 1, 'x':1}, {'id':2, 'x':2}) The above column will be created with IDENTITY, however the INSERT statement we emit is specifying explicit values. In the echo output we can see how SQLAlchemy handles this: .. sourcecode:: sql CREATE TABLE t ( id INTEGER NOT NULL IDENTITY(1,1), x INTEGER NULL, PRIMARY KEY (id) ) COMMIT SET IDENTITY_INSERT t ON INSERT INTO t (id, x) VALUES (?, ?) ((1, 1), (2, 2)) SET IDENTITY_INSERT t OFF COMMIT This is an auxiliary use case suitable for testing and bulk insert scenarios. MAX on VARCHAR / NVARCHAR ------------------------- SQL Server supports the special string "MAX" within the :class:`.sqltypes.VARCHAR` and :class:`.sqltypes.NVARCHAR` datatypes, to indicate "maximum length possible". The dialect currently handles this as a length of "None" in the base type, rather than supplying a dialect-specific version of these types, so that a base type specified such as ``VARCHAR(None)`` can assume "unlengthed" behavior on more than one backend without using dialect-specific types. To build a SQL Server VARCHAR or NVARCHAR with MAX length, use None:: my_table = Table( 'my_table', metadata, Column('my_data', VARCHAR(None)), Column('my_n_data', NVARCHAR(None)) ) Collation Support ----------------- Character collations are supported by the base string types, specified by the string argument "collation":: from sqlalchemy import VARCHAR Column('login', VARCHAR(32, collation='Latin1_General_CI_AS')) When such a column is associated with a :class:`.Table`, the CREATE TABLE statement for this column will yield:: login VARCHAR(32) COLLATE Latin1_General_CI_AS NULL LIMIT/OFFSET Support -------------------- MSSQL has no support for the LIMIT or OFFSET keywords. LIMIT is supported directly through the ``TOP`` Transact SQL keyword:: select.limit will yield:: SELECT TOP n If using SQL Server 2005 or above, LIMIT with OFFSET support is available through the ``ROW_NUMBER OVER`` construct. For versions below 2005, LIMIT with OFFSET usage will fail. .. _mssql_isolation_level: Transaction Isolation Level --------------------------- All SQL Server dialects support setting of transaction isolation level both via a dialect-specific parameter :paramref:`.create_engine.isolation_level` accepted by :func:`.create_engine`, as well as the :paramref:`.Connection.execution_options.isolation_level` argument as passed to :meth:`.Connection.execution_options`. This feature works by issuing the command ``SET TRANSACTION ISOLATION LEVEL `` for each new connection. To set isolation level using :func:`.create_engine`:: engine = create_engine( "mssql+pyodbc://scott:tiger@ms_2008", isolation_level="REPEATABLE READ" ) To set using per-connection execution options:: connection = engine.connect() connection = connection.execution_options( isolation_level="READ COMMITTED" ) Valid values for ``isolation_level`` include: * ``AUTOCOMMIT`` - pyodbc / pymssql-specific * ``READ COMMITTED`` * ``READ UNCOMMITTED`` * ``REPEATABLE READ`` * ``SERIALIZABLE`` * ``SNAPSHOT`` - specific to SQL Server .. versionadded:: 1.1 support for isolation level setting on Microsoft SQL Server. .. versionadded:: 1.2 added AUTOCOMMIT isolation level setting Nullability ----------- MSSQL has support for three levels of column nullability. The default nullability allows nulls and is explicit in the CREATE TABLE construct:: name VARCHAR(20) NULL If ``nullable=None`` is specified then no specification is made. In other words the database's configured default is used. This will render:: name VARCHAR(20) If ``nullable`` is ``True`` or ``False`` then the column will be ``NULL`` or ``NOT NULL`` respectively. Date / Time Handling -------------------- DATE and TIME are supported. Bind parameters are converted to datetime.datetime() objects as required by most MSSQL drivers, and results are processed from strings if needed. The DATE and TIME types are not available for MSSQL 2005 and previous - if a server version below 2008 is detected, DDL for these types will be issued as DATETIME. .. _mssql_large_type_deprecation: Large Text/Binary Type Deprecation ---------------------------------- Per `SQL Server 2012/2014 Documentation `_, the ``NTEXT``, ``TEXT`` and ``IMAGE`` datatypes are to be removed from SQL Server in a future release. SQLAlchemy normally relates these types to the :class:`.UnicodeText`, :class:`.Text` and :class:`.LargeBinary` datatypes. In order to accommodate this change, a new flag ``deprecate_large_types`` is added to the dialect, which will be automatically set based on detection of the server version in use, if not otherwise set by the user. The behavior of this flag is as follows: * When this flag is ``True``, the :class:`.UnicodeText`, :class:`.Text` and :class:`.LargeBinary` datatypes, when used to render DDL, will render the types ``NVARCHAR(max)``, ``VARCHAR(max)``, and ``VARBINARY(max)``, respectively. This is a new behavior as of the addition of this flag. * When this flag is ``False``, the :class:`.UnicodeText`, :class:`.Text` and :class:`.LargeBinary` datatypes, when used to render DDL, will render the types ``NTEXT``, ``TEXT``, and ``IMAGE``, respectively. This is the long-standing behavior of these types. * The flag begins with the value ``None``, before a database connection is established. If the dialect is used to render DDL without the flag being set, it is interpreted the same as ``False``. * On first connection, the dialect detects if SQL Server version 2012 or greater is in use; if the flag is still at ``None``, it sets it to ``True`` or ``False`` based on whether 2012 or greater is detected. * The flag can be set to either ``True`` or ``False`` when the dialect is created, typically via :func:`.create_engine`:: eng = create_engine("mssql+pymssql://user:pass@host/db", deprecate_large_types=True) * Complete control over whether the "old" or "new" types are rendered is available in all SQLAlchemy versions by using the UPPERCASE type objects instead: :class:`.NVARCHAR`, :class:`.VARCHAR`, :class:`.types.VARBINARY`, :class:`.TEXT`, :class:`.mssql.NTEXT`, :class:`.mssql.IMAGE` will always remain fixed and always output exactly that type. .. versionadded:: 1.0.0 .. _multipart_schema_names: Multipart Schema Names ---------------------- SQL Server schemas sometimes require multiple parts to their "schema" qualifier, that is, including the database name and owner name as separate tokens, such as ``mydatabase.dbo.some_table``. These multipart names can be set at once using the :paramref:`.Table.schema` argument of :class:`.Table`:: Table( "some_table", metadata, Column("q", String(50)), schema="mydatabase.dbo" ) When performing operations such as table or component reflection, a schema argument that contains a dot will be split into separate "database" and "owner" components in order to correctly query the SQL Server information schema tables, as these two values are stored separately. Additionally, when rendering the schema name for DDL or SQL, the two components will be quoted separately for case sensitive names and other special characters. Given an argument as below:: Table( "some_table", metadata, Column("q", String(50)), schema="MyDataBase.dbo" ) The above schema would be rendered as ``[MyDataBase].dbo``, and also in reflection, would be reflected using "dbo" as the owner and "MyDataBase" as the database name. To control how the schema name is broken into database / owner, specify brackets (which in SQL Server are quoting characters) in the name. Below, the "owner" will be considered as ``MyDataBase.dbo`` and the "database" will be None:: Table( "some_table", metadata, Column("q", String(50)), schema="[MyDataBase.dbo]" ) To individually specify both database and owner name with special characters or embedded dots, use two sets of brackets:: Table( "some_table", metadata, Column("q", String(50)), schema="[MyDataBase.Period].[MyOwner.Dot]" ) .. versionchanged:: 1.2 the SQL Server dialect now treats brackets as identifier delimeters splitting the schema into separate database and owner tokens, to allow dots within either name itself. .. _legacy_schema_rendering: Legacy Schema Mode ------------------ Very old versions of the MSSQL dialect introduced the behavior such that a schema-qualified table would be auto-aliased when used in a SELECT statement; given a table:: account_table = Table( 'account', metadata, Column('id', Integer, primary_key=True), Column('info', String(100)), schema="customer_schema" ) this legacy mode of rendering would assume that "customer_schema.account" would not be accepted by all parts of the SQL statement, as illustrated below:: >>> eng = create_engine("mssql+pymssql://mydsn", legacy_schema_aliasing=True) >>> print(account_table.select().compile(eng)) SELECT account_1.id, account_1.info FROM customer_schema.account AS account_1 This mode of behavior is now off by default, as it appears to have served no purpose; however in the case that legacy applications rely upon it, it is available using the ``legacy_schema_aliasing`` argument to :func:`.create_engine` as illustrated above. .. versionchanged:: 1.1 the ``legacy_schema_aliasing`` flag introduced in version 1.0.5 to allow disabling of legacy mode for schemas now defaults to False. .. _mssql_indexes: Clustered Index Support ----------------------- The MSSQL dialect supports clustered indexes (and primary keys) via the ``mssql_clustered`` option. This option is available to :class:`.Index`, :class:`.UniqueConstraint`. and :class:`.PrimaryKeyConstraint`. To generate a clustered index:: Index("my_index", table.c.x, mssql_clustered=True) which renders the index as ``CREATE CLUSTERED INDEX my_index ON table (x)``. To generate a clustered primary key use:: Table('my_table', metadata, Column('x', ...), Column('y', ...), PrimaryKeyConstraint("x", "y", mssql_clustered=True)) which will render the table, for example, as:: CREATE TABLE my_table (x INTEGER NOT NULL, y INTEGER NOT NULL, PRIMARY KEY CLUSTERED (x, y)) Similarly, we can generate a clustered unique constraint using:: Table('my_table', metadata, Column('x', ...), Column('y', ...), PrimaryKeyConstraint("x"), UniqueConstraint("y", mssql_clustered=True), ) To explicitly request a non-clustered primary key (for example, when a separate clustered index is desired), use:: Table('my_table', metadata, Column('x', ...), Column('y', ...), PrimaryKeyConstraint("x", "y", mssql_clustered=False)) which will render the table, for example, as:: CREATE TABLE my_table (x INTEGER NOT NULL, y INTEGER NOT NULL, PRIMARY KEY NONCLUSTERED (x, y)) .. versionchanged:: 1.1 the ``mssql_clustered`` option now defaults to None, rather than False. ``mssql_clustered=False`` now explicitly renders the NONCLUSTERED clause, whereas None omits the CLUSTERED clause entirely, allowing SQL Server defaults to take effect. MSSQL-Specific Index Options ----------------------------- In addition to clustering, the MSSQL dialect supports other special options for :class:`.Index`. INCLUDE ^^^^^^^ The ``mssql_include`` option renders INCLUDE(colname) for the given string names:: Index("my_index", table.c.x, mssql_include=['y']) would render the index as ``CREATE INDEX my_index ON table (x) INCLUDE (y)`` .. _mssql_index_where: Filtered Indexes ^^^^^^^^^^^^^^^^ The ``mssql_where`` option renders WHERE(condition) for the given string names:: Index("my_index", table.c.x, mssql_where=table.c.x > 10) would render the index as ``CREATE INDEX my_index ON table (x) WHERE x > 10``. .. versionadded:: 1.3.4 Index ordering ^^^^^^^^^^^^^^ Index ordering is available via functional expressions, such as:: Index("my_index", table.c.x.desc()) would render the index as ``CREATE INDEX my_index ON table (x DESC)`` .. seealso:: :ref:`schema_indexes_functional` Compatibility Levels -------------------- MSSQL supports the notion of setting compatibility levels at the database level. This allows, for instance, to run a database that is compatible with SQL2000 while running on a SQL2005 database server. ``server_version_info`` will always return the database server version information (in this case SQL2005) and not the compatibility level information. Because of this, if running under a backwards compatibility mode SQLAlchemy may attempt to use T-SQL statements that are unable to be parsed by the database server. Triggers -------- SQLAlchemy by default uses OUTPUT INSERTED to get at newly generated primary key values via IDENTITY columns or other server side defaults. MS-SQL does not allow the usage of OUTPUT INSERTED on tables that have triggers. To disable the usage of OUTPUT INSERTED on a per-table basis, specify ``implicit_returning=False`` for each :class:`.Table` which has triggers:: Table('mytable', metadata, Column('id', Integer, primary_key=True), # ..., implicit_returning=False ) Declarative form:: class MyClass(Base): # ... __table_args__ = {'implicit_returning':False} This option can also be specified engine-wide using the ``implicit_returning=False`` argument on :func:`.create_engine`. .. _mssql_rowcount_versioning: Rowcount Support / ORM Versioning --------------------------------- The SQL Server drivers may have limited ability to return the number of rows updated from an UPDATE or DELETE statement. As of this writing, the PyODBC driver is not able to return a rowcount when OUTPUT INSERTED is used. This impacts the SQLAlchemy ORM's versioning feature in many cases where server-side value generators are in use in that while the versioning operations can succeed, the ORM cannot always check that an UPDATE or DELETE statement matched the number of rows expected, which is how it verifies that the version identifier matched. When this condition occurs, a warning will be emitted but the operation will proceed. The use of OUTPUT INSERTED can be disabled by setting the :paramref:`.Table.implicit_returning` flag to ``False`` on a particular :class:`.Table`, which in declarative looks like:: class MyTable(Base): __tablename__ = 'mytable' id = Column(Integer, primary_key=True) stuff = Column(String(10)) timestamp = Column(TIMESTAMP(), default=text('DEFAULT')) __mapper_args__ = { 'version_id_col': timestamp, 'version_id_generator': False, } __table_args__ = { 'implicit_returning': False } Enabling Snapshot Isolation --------------------------- SQL Server has a default transaction isolation mode that locks entire tables, and causes even mildly concurrent applications to have long held locks and frequent deadlocks. Enabling snapshot isolation for the database as a whole is recommended for modern levels of concurrency support. This is accomplished via the following ALTER DATABASE commands executed at the SQL prompt:: ALTER DATABASE MyDatabase SET ALLOW_SNAPSHOT_ISOLATION ON ALTER DATABASE MyDatabase SET READ_COMMITTED_SNAPSHOT ON Background on SQL Server snapshot isolation is available at http://msdn.microsoft.com/en-us/library/ms175095.aspx. iNi(tinformation_schemai(tengine(texc(tschema(tsql(ttypes(tutil(tdefault(t reflection(tcompiler(t expression(t quoted_name(tBIGINT(tBINARY(tCHAR(tDATE(tDATETIME(tDECIMAL(tFLOAT(tINTEGER(tNCHAR(tNUMERIC(tNVARCHAR(tSMALLINT(tTEXT(tVARCHAR(tupdate_wrapperi i i i i itaddtalltaltertandtanytastasct authorizationtbackuptbegintbetweentbreaktbrowsetbulktbytcascadetcasetcheckt checkpointtcloset clusteredtcoalescetcollatetcolumntcommittcomputet constrainttcontainst containstabletcontinuetconverttcreatetcrosstcurrentt current_datet current_timetcurrent_timestampt current_usertcursortdatabasetdbcct deallocatetdeclareRtdeletetdenytdesctdisktdistinctt distributedtdoubletdroptdumptelsetendterrlvltescapetexcepttexectexecutetexiststexittexternaltfetchtfilet fillfactortfortforeigntfreetextt freetexttabletfromtfulltfunctiontgototgranttgroupthavingtholdlocktidentitytidentity_insertt identitycoltiftintindextinnertinsertt intersecttintotistjointkeytkilltlefttliketlinenotloadtmergetnationaltnocheckt nonclusteredtnottnulltnulliftoftofftoffsetstontopentopendatasourcet openqueryt openrowsettopenxmltoptiontortordertoutertovertpercenttpivottplant precisiontprimarytprinttproct proceduretpublict raiserrortreadtreadtextt reconfiguret referencest replicationtrestoretrestricttreturntreverttrevoketrighttrollbacktrowcountt rowguidcoltruletsaveRt securityaudittselectt session_usertsettsetusertshutdowntsomet statisticst system_userttablet tablesamplettextsizetthenttottopttrant transactionttriggerttruncatettsequaltuniontuniquetunpivottupdatet updatetexttusetusertvaluestvaryingtviewtwaitfortwhentwheretwhiletwitht writetexttREALcBseZdZdZRS(RcKs*|jddtt|j|dS(NRi(t setdefaulttsuperRt__init__(tselftkw((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR|s(t__name__t __module__t__visit_name__R(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRystTINYINTcBseZdZRS(R(RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst_MSDatecBs)eZdZejdZdZRS(cCs d}|S(NcSs9t|tjkr1tj|j|j|jS|SdS(N(ttypetdatetimetdatetyeartmonthtday(tvalue((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytprocesss((RtdialectR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytbind_processors s(\d+)-(\d+)-(\d+)csfd}|S(Ncst|tjr|jSt|tjrjj|}|s\td|fntjg|jD]}t |pd^qoS|SdS(Ns"could not parse %r as a date valuei( t isinstanceRRRt string_typest_regtmatcht ValueErrortgroupstint(Rtmtx(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs 2((RRtcoltypeR((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytresult_processors (RRRtretcompileRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs tTIMEcBsJeZddZejdddZdZej dZ dZ RS(cKs ||_tt|jdS(N(RRRR(RRtkwargs((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs ilicsfd}|S(Ncsdt|tjr3tjjj|j}n-t|tjr`tjjj|}n|S(N(RRtcombinet_TIME__zero_datettime(R(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs  ((RRR((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs s!(\d+):(\d+):(\d+)(?:\.(\d{0,6}))?csfd}|S(Ncst|tjr|jSt|tjrjj|}|s\td|fntjg|jD]}t |pd^qoS|SdS(Ns"could not parse %r as a time valuei( RRRRRRRRRR(RRR(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs 2((RRRR((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs N( RRtNoneRRRRRRRRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs   t _DateTimeBasecBseZdZRS(cCs d}|S(NcSs9t|tjkr1tj|j|j|jS|SdS(N(RRRRRR(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs((RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs (RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst _MSDateTimecBseZRS((RR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst SMALLDATETIMEcBseZdZRS(R(RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst DATETIME2cBseZdZddZRS(RcKs#tt|j|||_dS(N(RRRR(RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRsN(RRRRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRstDATETIMEOFFSETcBseZdZddZRS(RcKs ||_dS(N(R(RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRsN(RRRRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst_UnicodeLiteralcBseZdZRS(csfd}|S(Ncs;|jdd}jjr3|jdd}nd|S(Nt's''t%s%%sN'%s'(treplacetidentifier_preparert_double_percents(R(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs ((RRR((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytliteral_processors (RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst _MSUnicodecBseZRS((RR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst_MSUnicodeTextcBseZRS((RR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR st TIMESTAMPcBs/eZdZdZdZedZdZRS(sBImplement the SQL Server TIMESTAMP type. Note this is **completely different** than the SQL Standard TIMESTAMP type, which is not supported by SQL Server. It is a read-only datatype that does not support INSERT of values. .. versionadded:: 1.2 .. seealso:: :class:`.mssql.ROWVERSION` RcCs ||_dS(sConstruct a TIMESTAMP or ROWVERSION type. :param convert_int: if True, binary integer values will be converted to integers on read. .. versionadded:: 1.2 N(t convert_int(RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR!s cs?tt|j|||jr7fd}|SSdS(Ncs:|}|dk r6ttj|dd}n|S(Nthexi(RRtcodecstencode(R(tsuper_(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR0s  (RRRR(RRRR((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR,s  N( RRt__doc__RRtlengthtFalseRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR s   t ROWVERSIONcBseZdZdZRS(s(Implement the SQL Server ROWVERSION type. The ROWVERSION datatype is a SQL Server synonym for the TIMESTAMP datatype, however current SQL Server documentation suggests using ROWVERSION for new datatypes going forward. The ROWVERSION datatype does **not** reflect (e.g. introspect) from the database as itself; the returned datatype will be :class:`.mssql.TIMESTAMP`. This is a read-only datatype that does not support INSERT of values. .. versionadded:: 1.2 .. seealso:: :class:`.mssql.TIMESTAMP` R (RRR R(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR <stNTEXTcBseZdZdZRS(sMMSSQL NTEXT type, for variable-length unicode text up to 2^30 characters.R (RRR R(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR Tst VARBINARYcBseZdZdZRS(sGThe MSSQL VARBINARY type. This type is present to support "deprecate_large_types" mode where either ``VARBINARY(max)`` or IMAGE is rendered. Otherwise, this type object is redundant vs. :class:`.types.VARBINARY`. .. versionadded:: 1.0.0 .. seealso:: :ref:`mssql_large_type_deprecation` R(RRR R(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR\stIMAGEcBseZdZRS(R(RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRpstXMLcBseZdZdZRS(s"MSSQL XML type. This is a placeholder type for reflection purposes that does not include any Python-side datatype support. It also does not currently support additional arguments, such as "CONTENT", "DOCUMENT", "xml_schema_collection". .. versionadded:: 1.1.11 R(RRR R(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRts tBITcBseZdZRS(R(RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRstMONEYcBseZdZRS(R(RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst SMALLMONEYcBseZdZRS(R(RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRstUNIQUEIDENTIFIERcBseZdZRS(R(RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRst SQL_VARIANTcBseZdZRS(R(RRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRsRtbiginttsmallintttinyinttvarchartnvarchartchartncharttexttntexttdecimaltnumerictfloatRt datetime2tdatetimeoffsetRRt smalldatetimetbinaryt varbinarytbittrealtimagetxmlt timestamptmoneyt smallmoneytuniqueidentifiert sql_varianttMSTypeCompilercBseZddZdZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ RS(cCst|ddr"d|j}nd}|s:|j}n|rQ|d|}ndjg||fD]}|dk rd|^qdS(sYExtend a string-type declaration with standard SQL COLLATE annotations. t collations COLLATE %ss(%s)t N(tgetattrRR1R Rs(Rtspecttype_R R1tc((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt_extends cKs5t|dd}|dkr"dSdi|d6SdS(NRRsFLOAT(%(precision)s)(R3R(RR5RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_FLOATs cKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_TINYINTscKs"|jdk rd|jSdSdS(NsDATETIMEOFFSET(%s)R(RR(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_DATETIMEOFFSETs cKs.t|dd}|dk r&d|SdSdS(NRsTIME(%s)R(R3R(RR5RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_TIMEs cKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_TIMESTAMPscKsdS(NR ((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_ROWVERSIONscKs.t|dd}|dk r&d|SdSdS(NRs DATETIME2(%s)R(R3R(RR5RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_DATETIME2s cKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_SMALLDATETIME scKs|j||S(N(tvisit_NVARCHAR(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_unicode scKs0|jjr|j||S|j||SdS(N(Rtdeprecate_large_typest visit_VARCHARt visit_TEXT(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_texts cKs0|jjr|j||S|j||SdS(N(RRBR@t visit_NTEXT(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_unicode_texts cKs|jd|S(NR (R7(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRFscKs|jd|S(NR(R7(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRDscKs|jd|d|jpdS(NRR tmax(R7R (RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRC!scKs|jd|S(NR(R7(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_CHAR$scKs|jd|S(NR(R7(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_NCHAR'scKs|jd|d|jpdS(NRR RH(R7R (RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR@*scKs6|jjtkr"|j||S|j||SdS(N(Rtserver_version_infotMS_2008_VERSIONtvisit_DATETIMEt visit_DATE(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_date-scKs6|jjtkr"|j||S|j||SdS(N(RRKRLRMR;(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_time3scKs0|jjr|j||S|j||SdS(N(RRBtvisit_VARBINARYt visit_IMAGE(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_large_binary9s cKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRR?scKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_XMLBscKs|jd|d|jpdS(NRR RH(R7R (RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRQEscKs |j|S(N(t visit_BIT(RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_booleanHscKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRUKscKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_MONEYNscKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_SMALLMONEYQscKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_UNIQUEIDENTIFIERTscKsdS(NR((RR5R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_SQL_VARIANTWsN(!RRRR7R8R9R:R;R<R=R>R?RARERGRFRDRCRIRJR@RORPRSRRRTRQRVRURWRXRYRZ(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR0s<                             tMSExecutionContextcBsVeZeZeZdZdZdZdZ dZ dZ dZ dZ RS(cCs(|jjs |jj|dS|SdS(Ni(Rtsupports_unicode_statementst_encoder(Rt statement((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt _opt_encodeas cCsj|jrf|jjj}|j}|dk }|r|j|jdkp|jjjo|jjj r|j|jjjdkp||jjjdkp|jjj o|j|jjjkp||jjjk|_ n t |_ |jj o|o|jj o|j o|j |_|j rf|jj|j|jd|jjj|d|qfndS(s#Activate IDENTITY_INSERT if needed.isSET IDENTITY_INSERT %s ONN((tisinserttcompiledR^Rt_autoincrement_columnRRttcompiled_parameterst parameterst_has_multi_parameterst_enable_identity_insertR tinlinet returningt executemanyt_select_lastrowidtroot_connectiont_cursor_executeRAR_RRt format_table(Rttblt seq_columntinsert_has_sequence((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytpre_execgs>          cCs|j}|jr||jjr:|j|jdd|n|j|jdd||jjd}t|d|_n|j s|j s|j r|j j rtj||_n|jr|j|j|jd|jjj|j jjd|ndS( s#Disable IDENTITY_INSERT if enabled.s$SELECT scope_identity() AS lastrowidsSELECT @@identity AS lastrowidisSET IDENTITY_INSERT %s OFFN((((RkRjRtuse_scope_identityRlRAtfetchallRt _lastrowidR`tisupdatetisdeleteRaRhRtFullyBufferedResultProxyt _result_proxyRfR_RRmR^R(Rtconntrow((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt post_execs0       cCs|jS(N(Rt(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt get_lastrowidscCs]|jrYy9|jj|jd|jjj|jjj WqYt k rUqYXndS(NsSET IDENTITY_INSERT %s OFF( RfRARUR_RRRmRaR^Rt Exception(Rte((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pythandle_dbapi_exceptions    cCs!|jr|jStj|SdS(N(RxRt ResultProxy(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytget_result_proxys N(RRR RfRjRRxRtR_RqR{R|RR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR[[s  8 &  t MSSQLCompilercBs}eZeZejejjidd6dd6dd6dd6ZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZe eedZe dZe d(dZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*RS()t dayofyeartdoytweekdaytdowt millisecondt millisecondst microsecondt microsecondscOs&i|_tt|j||dS(N(t tablealiasesRRR(RtargsR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs csfd}|S(NcsH|jjr|||Sttt|j}|||SdS(N(Rtlegacy_schema_aliasingR3RRR(RtargRR(tfn(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytdecorates ((RR((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt_with_legacy_schema_aliasingscKsdS(NtCURRENT_TIMESTAMP((RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_now_funcscKsdS(Ns GETDATE()((RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_current_date_funcscKsd|j||S(NsLEN%s(tfunction_argspec(RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_length_funcscKsd|j||S(NsLEN%s(R(RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_char_length_funcscKs,d|j|j||j|j|fS(Ns%s + %s(RRvR(RR%toperatorR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_concat_op_binaryscKsdS(Nt1((RtexprR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_true scKsdS(Nt0((RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt visit_false scKs,d|j|j||j|j|fS(NsCONTAINS (%s, %s)(RRvR(RR%RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_match_op_binaryscKsgd}|jr|d7}n|jrC|j rC|d|j7}n|rM|Stjj|||SdS(s- MS-SQL puts TOP, it's version of LIMIT here ts DISTINCT sTOP %d N(t _distinctt_simple_int_limitt_offsett_limitR t SQLCompilertget_select_precolumns(RRRts((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs   cCs|S(N((RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytget_from_hint_text*scCs|S(N((RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytget_crud_hint_text-scKsdS(NR((RRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt limit_clause0sc Ks|j r|jdk s;|jdk r2|j s;|jrt|dd r|jjslt j dng|jjD]}t j |^qy}|j}|j}||d<|j }t|_|jtjjjd|jdjdj}tjd}tjg|jD]}|jdkr |^q } |dk r| j||k|dk r| j|||kqn| j||k|j| |Stjj|||SdS(sLook for ``LIMIT`` and OFFSET in a select statement, and if so tries to wrap it in a subquery with ``row_number()`` criterion. t _mssql_visitsLMSSQL requires an order_by when using an OFFSET or a non-simple LIMIT clausetselect_wraps_fortorder_bytmssql_rnN( Rt _limit_clauseRt_offset_clauset_simple_int_offsetRR3t_order_by_clausetclausesRt CompileErrortsql_utiltunwrap_label_referencet _generatetTrueRR2Rtfunct ROW_NUMBERRtlabelRtaliasRR6Rttappend_whereclauseRR Rt visit_select( RRRtelemt_order_by_clausesRt offset_clauseRR6t limitselect((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR4s>    %       .  cKsy||ks|r+tt|j||S|j|}|dk r\|j|d||Stt|j||SdS(Nt mssql_aliased(RRt visit_tablet_schema_aliased_tableRR(RRRtiscrudRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRns  cKs&|j|ds(Rs(Rt update_stmtt from_tablet extra_fromsRR((RRRsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytupdate_from_clauses cCs4t}|rt}n|j|dtdtd|S(s=If we have extra froms make sure we render any alias as hint.RRtashint(R RR(Rt delete_stmtRRR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytdelete_table_clauses  c s.ddjfd|g|DS(sjRender the DELETE .. FROM clause specific to MSSQL. Yes, it has the FROM keyword twice. sFROM s, c3s-|]#}|jdtdVqdS(RRN(RR(RR(RRR(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pys s(Rs(RRRRRR((RRRsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytdelete_extra_from_clauses cCsdS(NsSELECT 1 WHERE 1!=1((RR5((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_empty_set_exprsN(+RRRtreturning_precedes_valuesRt update_copyR RRRRRRRRRRRRRRRRRR RRRRRRRRRRRRRRRRRR(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRsT                :             tMSSQLStrictCompilercBs/eZdZeZdZdZdZRS(sA subclass of MSSQLCompiler which disables the usage of bind parameters where not allowed natively by MS-SQL. A dialect may use this compiler on a platform where native binds are used. cKs6t|dsRRRs WHERE tincludes INCLUDE (%s)(telementt_verify_index_tableRRRRt_prepared_index_nameRmRRst expressionsRRR RRRRR6tquoteR( RR:RRmRRR/t whereclausetwhere_compiledtcolt inclusionsR6((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_create_indexs8           C -cCs2d|j|jdt|jj|jjfS(Ns DROP INDEX %s ON %sR(R"R R RRmR(RRM((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_drop_indexscst|dkrdSd}|jdk rH|djj|7}n|d7}|jdd}|dk r|r|d7}q|d7}n|d d jfd |D7}|j|7}|S( NiRsCONSTRAINT %s s PRIMARY KEY R R/s CLUSTERED s NONCLUSTERED s(%s)s, c3s$|]}jj|jVqdS(N(RR$R(RR6(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pys s(tlenRRRtformat_constraintRRstdefine_constraint_deferrability(RR5RR/((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_primary_key_constraints      cst|dkrdSd}|jdk rH|djj|7}n|d7}|jdd}|dk r|r|d7}q|d7}n|d d jfd |D7}|j|7}|S( NiRsCONSTRAINT %s sUNIQUE R R/s CLUSTERED s NONCLUSTERED s(%s)s, c3s$|]}jj|jVqdS(N(RR$R(RR6(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pys s(R+RRRR,RRsR-(RR5RR/((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytvisit_unique_constraints      (RRRR R)R*R.R/(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR Ps  C 2  tMSIdentifierPreparercBs,eZeZdZdZddZRS(cCs,tt|j|dddddtdS(Nt initial_quotet[t final_quotet]tquote_case_sensitive_collations(RR0RR (RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs cCs|S(N((RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt_escape_identifierscCs{|dk rtjdnt|\}}|rYd|j||j|f}n|rq|j|}nd}|S(s'Prepare a quoted table and schema name.sThe IdentifierPreparer.quote_schema.force parameter is deprecated and will be removed in a future release. This flag has no effect on the behavior of the IdentifierPreparer.quote method; please refer to quoted_name().s%s.%sRN(RRRt_schema_elementsR$(RRtforcetdbnametownertresult((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt quote_schema s  %N(RRtRESERVED_WORDStreserved_wordsRR6RR<(((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR0s  csdfd}t|S(Nc s7t||\}}t||||||||S(N(t_owner_plus_dbt _switch_db(Rt connectionRRR9R:(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytwrap$s(RR(RRB((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt_db_plus_owner_listing#scsdfd}t|S(Nc s:t||\}}t||||||||| S(N(R?R@(RRAt tablenameRRR9R:(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRB6s(RR(RRB((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt_db_plus_owner5scOs\|r)|jd}|jd|nz|||SWd|rW|jd|nXdS(Nsselect db_name()suse %s(tscalarRU(R9RARRRt current_db((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR@HscCs7|sd|jfSd|kr)t|Sd|fSdS(Nt.(Rtdefault_schema_nameR7(RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR?Ss    cCst|tr"|jr"d|fSg}d}t}xtjd|D]o}|sYqGn|dkrnt}qG|dkrt}qG| r|dkr|j|d}qG||7}qGW|r|j|nt |dkr|ddj |dfSt |rd|dfSdSdS( NRs (\[|\]|\.)R2R4RHii(NN( RR R$RR RtsplitRtappendR+Rs(Rtpushtsymboltbracketttoken((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyR7\s.        t MSDialectcBsxeZdZeZeZeZeZ dZ dZ ie e j6ee j6ee j6ee j6ee j6ZejjjdejfgZeZeZeZ eZ!eZ"d!Z#e$Z%e&Z'e(Z)e*Z+e,j-id"d6fe,j/id"d6fe,j0id"d6d"d6d"d6fe,j1idd6dd 6fgZ2d"ed"dd"d"ed Z3d Z4d Z5e6d ddddgZ7dZ8dZ9dZ:dZ;dZ<dZ=e>dZ?e@jAdZBe@jAeCdZDe@jAeCdZEe@jAe>dZFe@jAe>dZGe@jAe>dZHe@jAe>dZIe@jAe>d ZJRS(#R itdboRR/RRiR R c Kszt|p d|_||_||_t|p3dp?|j|_||_||_tt|j |||_ dS(Ni( Rt query_timeoutt schema_nameRrtmax_identifier_lengthRBRRRPRtisolation_level( RRRRrRTRSRURBRtopts((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRs     cCs*|jdtt|j||dS(Ns$IF @@TRANCOUNT = 0 BEGIN TRANSACTION(RURRPt do_savepoint(RRAR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRWs cCsdS(N((RRAR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytdo_release_savepointst SERIALIZABLEsREAD UNCOMMITTEDsREAD COMMITTEDsREPEATABLE READtSNAPSHOTcCs|jdd}||jkrOtjd||jdj|jfn|j}|jd||j|dkr|j ndS(Nt_R2sLInvalid value '%s' for isolation_level. Valid isolation levels for %s are %ss, s"SET TRANSACTION ISOLATION LEVEL %sRZ( Rt_isolation_lookupRt ArgumentErrorRRsRARUR.R3(RRAtlevelRA((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytset_isolation_levels%   cCs|jtkrtdnd}d}x|D]x}|j}zXy%|jd||jd}Wn"|jjk r}|}w1n X|j SWd|j Xq1Wt j d||ftddS( Ns4Can't fetch isolation level prior to SQL Server 2005ssys.dm_exec_sessionsssys.dm_pdw_nodes_exec_sessionss SELECT CASE transaction_isolation_level WHEN 0 THEN NULL WHEN 1 THEN 'READ UNCOMMITTED' WHEN 2 THEN 'READ COMMITTED' WHEN 3 THEN 'REPEATABLE READ' WHEN 4 THEN 'SERIALIZABLE' WHEN 5 THEN 'SNAPSHOT' END AS TRANSACTION_ISOLATION_LEVEL FROM %s where session_id = @@SPID isQCould not fetch transaction isolation level, tried views: %s; final error was: %ssACan't fetch isolation level on this particular SQL Server version(ssys.dm_exec_sessionsssys.dm_pdw_nodes_exec_sessions( RKtMS_2005_VERSIONtNotImplementedErrorRRARUtfetchonetdbapitErrortupperR.Rtwarn(RRAt last_errortviewsRRAtvalterr((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytget_isolation_levels.    cCs$tt|j||jdS(N(RRPt initializet_setup_version_attributes(RRA((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRl scs*jdk r"fd}|SdSdS(Ncsj|jdS(N(R_RU(Ry(R(sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytconnect s(RUR(RRn((RsQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt on_connect scCs|jdttddkrLtjddjd|jDn|jtkrvd|jkrvt|_ n|jt krt|_ n|j dkr|jtk|_ ndS(Niiis[Unrecognized server version info '%s'. Some SQL Server features may not function properly.RHcss|]}t|VqdS(N(R(RR((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pys  stimplicit_returning(RKtlisttrangeRRfRsR`t__dict__RRpRLtsupports_multivalues_insertRBRtMS_2012_VERSION(R((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyRm s"!  cCsX|jtkr|jStjd}|j|}|dk rMtj|S|jSdS(NsSELECT schema_name()( RKR`RSRRRFRRt text_type(RRAtqueryRI((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt_get_default_schema_name, s  c Csvtj}|jj|k}|rBtj||jj|k}ntj|g|}|j|} | j dk S(N( tischemaRR6t table_nameRtand_t table_schemaRRUtfirstR( RRARDR9R:RRR%RR6((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt has_table7 s cKsWtjtjjjgdtjjjg}g|j|D]}|d^q=}|S(NRi(RRRytschemataR6RSRU(RRARRtrt schema_names((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytget_schema_namesE s &c Kstj}tj|jjgtj|jj|k|jjdkd|jjg}g|j |D]}|d^qg} | S(Ns BASE TABLERi( RyttablesRRR6RzR{R|t table_typeRU( RRAR9R:RRRRRt table_names((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytget_table_namesN s  &c Kstj}tj|jjgtj|jj|k|jjdkd|jjg}g|j |D]}|d^qg} | S(NtVIEWRi( RyRRRR6RzR{R|RRU( RRAR9R:RRRRRt view_names((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytget_view_names] s  $&c Ksl|jtkrgS|jtjdjtjd|tjtjd|tjj dt j }i}x?|D]7} i| dd6| ddkd6gd6|| d |D]6} | d |kr"|| d dj | dq"q"Wt |jS( Ns select ind.index_id, ind.is_unique, ind.name from sys.indexes as ind join sys.tables as tab on ind.object_id=tab.object_id join sys.schemas as sch on sch.schema_id=tab.schema_id where tab.name = :tabname and sch.name=:schname and ind.is_primary_key=0 and ind.type != 0ttabnametschnameRt is_uniqueiRt column_namestindex_idsRselect ind_col.index_id, ind_col.object_id, col.name from sys.columns as col join sys.tables as tab on tab.object_id=col.object_id join sys.index_columns as ind_col on (ind_col.column_id=col.column_id and ind_col.object_id=tab.object_id) join sys.schemas as sch on sch.schema_id=tab.schema_id where tab.name=:tabname and sch.name=:schname(RKR`RURRt bindparamst bindparamRyt CoerceUnicodeRtsqltypestUnicodeRKRqR( RRARDR9R:RRtrptindexesRz((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pyt get_indexesk s0 !   ! $c Ksh|jtjdjtjd|tjtjd|tj}|rd|j}|SdS(Nsselect definition from sys.sql_modules as mod, sys.views as views, sys.schemas as sch where mod.object_id=views.object_id and views.schema_id=sch.schema_id and views.name=:viewname and sch.name=:schnametviewnameR(RURRRRRyRRF( RRARR9R:RRRtview_def((sQ/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/mssql/base.pytget_view_definition s ! c Kstj}|r<tj|jj|k|jj|k}n|jj|k}tj|g|d|jjg} |j | } g} xt rd| j } | dkrPn| |jj | |jj| |jjdk| |jj| |jj| |jj| |jj| |jjf\} }}}}}}}|jj|d}i}|tttttttttj f kr|dkrd}n||d<|r||dsj             &  / E/(