L i<4ddlmZddlmZddlZddlmZddlmZddlmZddlmZddlm Z dd lm Z d d l m Z d d l mZejr6d dlmZd dlmZd dlmZd dlmZd dl mZd dlmZd dlmZd dlmZd dlmZGddZ ddZ y)) annotations) attrgetterN)Any)Callable)cast)Optional)Type)Union)url)util)Engine)_CoreAnyExecuteParams)CoreExecuteOptionsParameter)Dialect)URL) Executable) InvokeDDLBase) HasSchemaAttr) VisitableceZdZUddZeeedZded<eeee dZ ded<eeedZ d ed <dd Z dd Z dd Z ddZ d ddZy)MockConnectiondialectrc ||_||_yN)_dialect _execute_impl)selfrexecutes \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/engine/mock.py__init__zMockConnection.__init__$s $c|Srss r!zMockConnection.(s!r#renginerc.|jjSr)rnamer&s r!r(zMockConnection.*sQZZ__r#strr+c |Srr%)rkwargss r!connectzMockConnection.connect, r#c|jSr)schema)robjs r!schema_for_objectz MockConnection.schema_for_object/s zzr#c |Srr%)rkws r!execution_optionsz MockConnection.execution_options2r0r#c Vd|d<|d|j|d|j|y)NF checkfirst)r connectionr%)rtraverse_single)rvisitorcallableelementr.s r!_run_ddl_visitorzMockConnection._run_ddl_visitor5s6 %| LLT 5; /' "r#Nc&|j||Sr)r)rr3 parametersr7s r!r zMockConnection.execute@s !!#z22r#)rrr zCallable[..., Any])r.rreturnr)r3rrAz Optional[str])r6rrAr)r<zType[InvokeDDLBase]r=rr.rrANone)NN)r3rr@zOptional[_CoreAnyExecuteParams]r7z%Optional[CoreExecuteOptionsParameter]rAr)__name__ __module__ __qualname__r"rrpropertyr)__annotations__rrr+r/r4r7r>r r%r#r!rr#s%#x 45FF5C*Z*@!ABGWBS(#<=>D#> #, # # #  #7;CG 3 343A 3 3r#rc tj|}|j}i}tj|D]}||vs|j |||<|di|}t ||S)a?Create a "mock" engine used for echoing DDL. This is a utility function used for debugging or storing the output of DDL sequences as generated by :meth:`_schema.MetaData.create_all` and related methods. The function accepts a URL which is used only to determine the kind of dialect to be used, as well as an "executor" callable function which will receive a SQL expression object and parameters, which can then be echoed or otherwise printed. The executor's return value is not handled, nor does the engine allow regular string statements to be invoked, and is therefore only useful for DDL that is sent to the database without receiving any results. E.g.:: from sqlalchemy import create_mock_engine def dump(sql, *multiparams, **params): print(sql.compile(dialect=engine.dialect)) engine = create_mock_engine("postgresql+psycopg2://", dump) metadata.create_all(engine, checkfirst=False) :param url: A string URL which typically needs to contain only the database backend name. :param executor: a callable which receives the arguments ``sql``, ``*multiparams`` and ``**params``. The ``sql`` parameter is typically an instance of :class:`.ExecutableDDLElement`, which can then be compiled into a string using :meth:`.ExecutableDDLElement.compile`. .. versionadded:: 1.4 - the :func:`.create_mock_engine` function replaces the previous "mock" engine strategy used with :func:`_sa.create_engine`. .. seealso:: :ref:`faq_ddl_as_string` r%)_urlmake_url get_dialectrget_cls_kwargspopr)r executorr6u dialect_cls dialect_argskrs r!create_mock_enginerSIsq` cA--/KL   -( 7 ffQiLO( )L)G '8 ,,r#)r zUnion[str, URL]rNrr6rrAr)! __future__roperatorrtypingrrrrr r r rIr TYPE_CHECKINGbaser interfacesrrrrsql.basersql.ddlr sql.schemar sql.visitorsrrrSr%r#r!r_s~#  17#%'*(#3#3L=- =-$'=-/2=-=-r#