U ÂÏ a ã@sZddlmZddlmZddlmZddlmZddlmZGdd „d ej ƒZ d d „Z d S) é)Ú attrgetteré)Úbase)Úurlé)Úutil)Úddlc@szeZdZdd„Zedd„ƒZeedƒƒZedd„ƒZdd„Z d d „Z d d „Z d d„Z dd„Z dd„Zddd„Zdd„ZdS)ÚMockConnectioncCs||_||_dS©N)Ú_dialectÚexecute)ÚselfÚdialectr ©rúWC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\engine\mock.pyÚ__init__szMockConnection.__init__cCs|Sr r©ÚsrrrÚózMockConnection.r cCs|jjSr )r ÚnamerrrrrrcCs|jSr )Zschema)r ÚobjrrrÚschema_for_objectsz MockConnection.schema_for_objectcKs|Sr r)r ÚkwargsrrrÚconnectszMockConnection.connectcKs|Sr r)r ÚkwrrrÚexecution_optionssz MockConnection.execution_optionscKs|jj||fd|i|—ŽS)NÚengine)r Úcompiler)r Z statementÚ parametersrrrrr"sÿÿÿzMockConnection.compilercKs$d|d<tj|j|f|Ž |¡dS©NFZ checkfirst)rZSchemaGeneratorrÚtraverse_single©r ÚentityrrrrÚcreate'sÿzMockConnection.createcKs$d|d<tj|j|f|Ž |¡dSr )rZ SchemaDropperrr!r"rrrÚdrop.szMockConnection.dropNcKs"d|d<||j|f|Ž |¡dSr )rr!)r ZvisitorcallableÚelementÚ connectionrrrrÚ_run_ddl_visitor3szMockConnection._run_ddl_visitorcOs tƒ‚dSr )ÚNotImplementedError)r Zobject_Z multiparamsÚparamsrrrr 9szMockConnection.execute)N)Ú__name__Ú __module__Ú __qualname__rÚpropertyrrrrrrrrr$r%r(r rrrrr s   ÿ 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://', 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:`.DDLElement`, which can then be compiled into a string using :meth:`.DDLElement.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_dialectrZget_cls_kwargsÚpopr )rÚexecutorrÚuZ dialect_clsZ dialect_argsÚkrrrrÚcreate_mock_engine=s,  r5N) ÚoperatorrÚrrr/rZsqlrZ Connectabler r5rrrrÚs     -