1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
U
¸ý°dÒã@s$ddlmZddlmZddlZddlmZddlmZddlmZddlmZddlm    Z    dd    lm
Z
d
d l m Z d d l mZejrþd
dlmZd
dlmZd
dlmZd
dlmZd
dl mZd dlmZd dlmZd dlmZd dlmZd dlmZGdd„dƒZdddddœdd„Z dS)é)Ú annotations)Ú
attrgetterN)ÚAny)ÚCallable)Úcast)ÚOptional)ÚType)ÚUnioné)Úurlé)Úutil)ÚEngine)Ú_CoreAnyExecuteParams)ÚCoreExecuteOptionsParameter)ÚDialect)ÚURL)Ú
Executable)Ú SchemaDropper)ÚSchemaGenerator)Ú HasSchemaAttr)Ú
SchemaItemc@sÆeZdZUdddœdd„Zeeedd„ƒƒZded    <eeee    d
ƒƒƒZ
ded <eeed d„ƒƒZ d ed<dddœdd„Z dddœdd„Z dddœdd„Zdddddœdd „Zd(d"d#d$dd%œd&d'„Zd!S))ÚMockConnectionrzCallable[..., Any])ÚdialectÚexecutecCs||_||_dS©N)Ú_dialectÚ _execute_impl)Úselfrr©rúMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/engine/mock.pyÚ__init__%szMockConnection.__init__cCs|Srr©Úsrrr Ú<lambda>)ózMockConnection.<lambda>rÚenginerrcCs|jjSr)rÚnamer"rrr r$+r%Ústrr'r)ÚkwargsÚreturncKs|Srr)rr)rrr Úconnect-szMockConnection.connectrz Optional[str])Úobjr*cCs|jSr)Zschema)rr,rrr Úschema_for_object0sz MockConnection.schema_for_object)Úkwr*cKs|Srr)rr.rrr Úexecution_options3sz MockConnection.execution_optionsz+Type[Union[SchemaGenerator, SchemaDropper]]rÚNone)ÚvisitorcallableÚelementr)r*cKs"d|d<||j|f|Ž |¡dS)NFZ
checkfirst)rZtraverse_single)rr1r2r)rrr Ú_run_ddl_visitor6szMockConnection._run_ddl_visitorNrzOptional[_CoreAnyExecuteParams]z%Optional[CoreExecuteOptionsParameter])r,Ú
parametersr/r*cCs | ||¡Sr)r)rr,r4r/rrr r?szMockConnection.execute)NN)Ú__name__Ú
__module__Ú __qualname__r!rrÚpropertyr&Ú__annotations__rrr'r+r-r/r3rrrrr r$s
 ürrr)r Úexecutorr.r*cKsPt |¡}| ¡}i}t |¡D]}||kr | |¡||<q |f|Ž}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`
 
    )Ú_urlZmake_urlÚ get_dialectr Zget_cls_kwargsÚpopr)r r:r.ÚuZ dialect_clsZ dialect_argsÚkrrrr Úcreate_mock_engineHs,
 
r@)!Ú
__future__rÚoperatorrÚtypingrrrrrr    Úr r;r Ú TYPE_CHECKINGÚbaserZ
interfacesrrrrZsql.baserZsql.ddlrrZ
sql.schemarrrr@rrrr Ú<module>s.                    $