o
    i	                     @  s  U d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 ddl
T 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lmZ ddlmZ ddlmZ ddlmZ 	 dZejjeeedZded< dZ		 					d2d3d0d1ZdS )4    )annotationsN)Any)Mapping)Optional)urlparse   )*)ConnectionHrana)CursorHrana)ConnectFactory)
Connection)ConnectionTypes)Cursor)enable_callback_tracebacks)IsolationLevel)LEGACY_TRANSACTION_CONTROL)PathLike)RowzreStructuredText en)filelibsqlwswsszMapping[str, ConnectFactory]_connection_handlers)z	libsql://zws://zwss://      @ T   Fdatabaser   timeoutfloatdetect_typesintisolation_levelOptional[IsolationLevel]check_same_threadboolfactoryOptional[ConnectFactory]cached_statementsurikwargsr   returnr   c              
   K  s   |st | trtD ]}	| |	rd} nq	|s$tjj}
|dur#||d< n/|dur+|}
n(t | ts2J t| }zt|j	 }
W n t
yR } z	td|j	 |d}~ww |
| f||||||d|S )ac  
    Open a connection to an SQLite (local) or sqld (remote) database.

    In addition to :py:func:`sqlite3.connect`, this function allows
    connecting to remote servers using the following protocols:

    - ``libsql://`` alias for ``wss://``
    - ``ws://`` insecure web socket
    - ``wss://`` secure web socket

    If local files or ``:memory:`` is used, then the standard
    :py:class:`sqlite3.Connection` is returned.

    For remote URL, :py:class:`libsql_client.dbapi2.hrana.ConnectionHrana` is
    returned, it should match the behavior of
    :py:class:`sqlite3.Connection` whenever possible.
    TNr%   zunsupported uri scheme: )r   r   r!   r#   r'   r(   )
isinstancestr_uri_forced_databases_prefixes
startswithsqlite3dbapi2connectr   r   schemeKeyError
ValueError)r   r   r   r!   r#   r%   r'   r(   r)   prefixhandlerue r9   Q/home/ubuntu/.local/lib/python3.10/site-packages/libsql_client/dbapi2/__init__.pyr1   +   sB   
r1   )r   r   r   TNr   F)r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r    r(   r$   r)   r   r*   r   ) 
__future__r   sqlite3.dbapi2r/   typingr   r   r   urllib.parser   
_reexportshranar	   r   r
   r   typesr   BaseConnectionr   
BaseCursorr   r   r   r   r   __docformat__r0   r1   r   __annotations__r-   r9   r9   r9   r:   <module>   sD    