/
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
sqlalchemy
/
dialects
/
sqlite
/
up file
home
� 1��fc @ s d Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d d d � � YZ d e f d � � YZ d e f d � � YZ e Z d S( sZ .. 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 <asyncio_toplevel>` 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`. .. _aiosqlite_udfs: User-Defined Functions ---------------------- aiosqlite extends pysqlite to support async, so we can create our own user-defined functions (UDFs) in Python and use them directly in SQLite queries as described here: :ref:`pysqlite_udfs`. i ( t SQLiteExecutionContext( t SQLiteDialect_pysqlitei ( t pool( t util( t AdaptedConnection( t await_fallback( t await_onlyt AsyncAdapt_aiosqlite_cursorc B sk e Z d Z e Z d � Z d � Z d d � Z d � Z d � Z d � Z d � Z d d � Z d � Z RS( t _adapt_connectiont _connectiont descriptiont await_t _rowst arraysizet rowcountt lastrowidc C sI | | _ | j | _ | j | _ d | _ d | _ d | _ g | _ d S( Ni i����( R R R R R t NoneR R ( t selft adapt_connection( ( sW /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.pyt __init__G s c C s g | j (d S( N( R ( R ( ( sW /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.pyt closeP s c C s y� | j | j j � � } | d k r@ | j | j | � � n | j | j | | � � | j r� | j | _ d | _ | _ | j s� | j | j � � | _ q� n! d | _ | j | _ | j | _ | j s� | j | j � � n | | _ Wn# t k r} | j j | � n Xd S( Ni����( R R t cursorR t executeR R R t server_sidet fetchallR R t _cursort ExceptionR t _handle_exception( R t operationt parametersR t error( ( sW /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.pyR S s$ c C s� yi | j | j j � � } | j | j | | � � d | _ | j | _ | j | _ | j | j � � Wn# t k r� } | j j | � n Xd S( N( R R R t executemanyR R R R R R R R ( R R t seq_of_parametersR R ( ( sW /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.pyR n s c G s d S( N( ( R t inputsizes( ( sW /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.pyt setinputsizesy s c c s% x | j r | j j d � Vq Wd S( Ni ( R t pop( R ( ( sW /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.pyt __iter__| s c C s! | j r | j j d � Sd Sd S( Ni ( R R# R ( R ( ( sW /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.pyt fetchone� s c C s= | d k r | j } n | j d | !} | j | | j (| S( Ni ( R R R ( R t sizet retval( ( sW /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.pyt fetchmany� s c C s | j } g | j (| S( N( R ( R R'