U a'@sdZddlmZddlmZddlmZddlmZddlm Z ddlm Z Gd d d Z Gd d d e Z Gd ddZ Gddde ZGdddZGdddeZGdddeZeZdS)aV .. dialect:: sqlite+aiosqlite :name: aiosqlite :dbapi: aiosqlite :connectstring: sqlite+aiosqlite:///file_path :url: https://pypi.org/project/aiosqlite/ The aiosqlite dialect provides support for the SQLAlchemy asyncio interface running on top of pysqlite. aiosqlite is a wrapper around pysqlite that uses a background thread for each connection. It does not actually use non-blocking IO, as SQLite databases are not socket-based. However it does provide a working asyncio interface that's useful for testing and prototyping purposes. Using a special asyncio mediation layer, the aiosqlite dialect is usable as the backend for the :ref:`SQLAlchemy asyncio ` extension package. This dialect should normally be used only with the :func:`_asyncio.create_async_engine` engine creation function:: from sqlalchemy.ext.asyncio import create_async_engine engine = create_async_engine("sqlite+aiosqlite:///filename") The URL passes through all arguments to the ``pysqlite`` driver, so all connection arguments are the same as they are for that of :ref:`pysqlite`. )SQLiteExecutionContext)SQLiteDialect_pysqlite)pool)util)await_fallback) await_onlyc@s`eZdZdZdZddZddZddd Zd d Zd d Z ddZ ddZ dddZ ddZ dS)AsyncAdapt_aiosqlite_cursor)_adapt_connection _connection descriptionawait__rows arraysizerowcount lastrowidFcCs2||_|j|_|j|_d|_d|_d|_g|_dS)Nr)r r r rrr r)selfZadapt_connectionreC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\dialects\sqlite\aiosqlite.py__init__>sz$AsyncAdapt_aiosqlite_cursor.__init__cCsg|jdd<dSNrrrrrcloseGsz!AsyncAdapt_aiosqlite_cursor.closeNc Csz||j}|dkr,|||n|||||jrp|j|_d|_|_|js|||_ nd|_|j|_|j|_|js|| n||_ Wn.t k r}z|j |W5d}~XYnXdS)Nr)r r cursorexecuter rr server_sidefetchallrr_cursor Exceptionr _handle_exception)r operation parametersrerrorrrrrJs$  z#AsyncAdapt_aiosqlite_cursor.executec Cs~zJ||j}||||d|_|j|_|j|_||Wn.tk rx}z|j |W5d}~XYnXdSr) r r r executemanyr rrrr r r!)rr"Zseq_of_parametersrr$rrrr%esz'AsyncAdapt_aiosqlite_cursor.executemanycGsdSrr)rZ inputsizesrrr setinputsizespsz)AsyncAdapt_aiosqlite_cursor.setinputsizesccs|jr|jdVqdSNrpoprrrr__iter__ssz$AsyncAdapt_aiosqlite_cursor.__iter__cCs|jr|jdSdSdSr'r)rrrrfetchonews z$AsyncAdapt_aiosqlite_cursor.fetchonecCs8|dkr|j}|jd|}|j|d|jdd<|Sr')rr)rsizeretvalrrr fetchmany}s z%AsyncAdapt_aiosqlite_cursor.fetchmanycCs |jdd}g|jdd<|Srr)rr.rrrrsz$AsyncAdapt_aiosqlite_cursor.fetchall)N)N)__name__ __module__ __qualname__ __slots__rrrrr%r&r+r,r/rrrrrr 0s     r csFeZdZdZdZfddZddZddZdd d Zd d Z Z S)AsyncAdapt_aiosqlite_ss_cursorrTcstj||d|_dSr)superrr)rargkw __class__rrrsz'AsyncAdapt_aiosqlite_ss_cursor.__init__cCs$|jdk r ||jd|_dSr)rr rrrrrrs z$AsyncAdapt_aiosqlite_ss_cursor.closecCs||jSr)r rr,rrrrr,sz'AsyncAdapt_aiosqlite_ss_cursor.fetchoneNcCs"|dkr|j}||jj|dS)N)r-)rr rr/)rr-rrrr/sz(AsyncAdapt_aiosqlite_ss_cursor.fetchmanycCs||jSr)r rrrrrrrsz'AsyncAdapt_aiosqlite_ss_cursor.fetchall)N) r0r1r2r3rrrr,r/r __classcell__rrr8rr4s  r4c@steZdZeeZdZddZeddZ e j ddZ ddZ dd d Z d d Z ddZddZddZddZdS)AsyncAdapt_aiosqlite_connectiondbapir cCs||_||_dSrr<)rr= connectionrrrrsz(AsyncAdapt_aiosqlite_connection.__init__cCs|jjSr)r isolation_levelrrrrr?sz/AsyncAdapt_aiosqlite_connection.isolation_levelc Cs>z ||j_Wn,tk r8}z||W5d}~XYnXdSr)r r?r r!)rvaluer$rrrr?s c OsJz||jj||Wn,tk rD}z||W5d}~XYnXdSr)r r create_functionr r!)rargsr7r$rrrrAsz/AsyncAdapt_aiosqlite_connection.create_functionFcCs|r t|St|SdSr)r4r )rrrrrrsz&AsyncAdapt_aiosqlite_connection.cursorcOs||jj||Sr)r r r)rrBr7rrrrsz'AsyncAdapt_aiosqlite_connection.executec CsFz||jWn,tk r@}z||W5d}~XYnXdSr)r r rollbackr r!rr$rrrrCsz(AsyncAdapt_aiosqlite_connection.rollbackc CsFz||jWn,tk r@}z||W5d}~XYnXdSr)r r commitr r!rDrrrrEsz&AsyncAdapt_aiosqlite_connection.commitc CsFz||jWn,tk r@}z||W5d}~XYnXdSr)r r rr r!rDrrrrsz%AsyncAdapt_aiosqlite_connection.closecCs:t|tr2|jddkr2tj|jjd|dn|dS)Nr(no active connection)from_) isinstance ValueErrorrBrZraise_r=sqliteOperationalErrorrDrrrr!s  z1AsyncAdapt_aiosqlite_connection._handle_exceptionN)F)r0r1r2 staticmethodrr r3rpropertyr?setterrArrrCrErr!rrrrr;s   r;c@seZdZdZeeZdS)'AsyncAdaptFallback_aiosqlite_connectionrN)r0r1r2r3rLrr rrrrrOsrOc@s$eZdZddZddZddZdS)AsyncAdapt_aiosqlite_dbapicCs||_||_d|_|dS)NZqmark) aiosqliterJZ paramstyle_init_dbapi_attributes)rrQrJrrrrsz#AsyncAdapt_aiosqlite_dbapi.__init__cCs^dD]}t||t|j|qdD]}t||t|j|q"dD]}t||t|j|q@dS)N)Z DatabaseErrorErrorZIntegrityErrorZNotSupportedErrorrKZProgrammingErrorZsqlite_versionZsqlite_version_info)ZPARSE_COLNAMESZPARSE_DECLTYPES)Binary)setattrgetattrrQrJ)rnamerrrrRs  z1AsyncAdapt_aiosqlite_dbapi._init_dbapi_attributescOsR|dd}d|d<|jj||}d|_t|r@t|t|St|t |SdS)Nasync_fallbackFZcheck_same_threadT) r*rQconnectdaemonrZasboolrOrr;r)rr6r7rXr>rrrrYs  z"AsyncAdapt_aiosqlite_dbapi.connectN)r0r1r2rrRrYrrrrrPsrPc@seZdZddZdS) SQLiteExecutionContext_aiosqlitecCs|jjddS)NT)r)Z_dbapi_connectionrrrrrcreate_server_side_cursor(sz:SQLiteExecutionContext_aiosqlite.create_server_side_cursorN)r0r1r2r\rrrrr['sr[csHeZdZdZdZdZdZeZe ddZ e ddZ fddZ Z S) SQLiteDialect_aiosqliterQTcCsttdtdS)NrQZsqlite3)rP __import__)clsrrrr=6szSQLiteDialect_aiosqlite.dbapicCs||rtjStjSdSr)Z_is_url_file_dbrZNullPoolZ StaticPool)r_urlrrrget_pool_class<s z&SQLiteDialect_aiosqlite.get_pool_classcs.t||jjrdt|krdSt|||S)NrFT)rHr=rKstrr5 is_disconnect)rer>rr8rrrcCs z%SQLiteDialect_aiosqlite.is_disconnect)r0r1r2ZdriverZsupports_statement_cacheZis_asyncZsupports_server_side_cursorsr[Zexecution_ctx_cls classmethodr=rarcr:rrr8rr],s  r]N)__doc__baserZpysqliterrrZutil.concurrencyrrr r4r;rOrPr[r]dialectrrrrs      [B: