OwlCyberSecurity - MANAGER
Edit File: cursor.cpython-312.pyc
� Ɠ�g�� � �� � d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl m Z dZ ej d j e� ej ej z ej z � Z ej d ej ej z ej z � Z ej dj e� ej ej z ej z � Z ej dej ej z ej z � Z ej d � Z ej dej, � Z ej d� Z ej d� ZdZ G d� de� Zd� Z G d� de� Z G d� de� Z G d� de� Z G d� de� Z! G d� de � Z" G d� d e� Z# G d!� d"e� Z$ G d#� d$e� Z% G d%� d&e$e � Z& G d'� d(e%e � Z'y))zCursor classes � )� namedtupleN� )�errors)�MySQLCursorAbstract)�PY2z\/\*.*?\*\/z'({0})|(["'`][^"'`]*?({0})[^"'`]*?["'`])z<\s*ON\s+DUPLICATE\s+KEY(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$z&({0}|\s)*INSERT({0}|\s)*INTO.+VALUES.*z.*VALUES\s*(\(.*\)).*s (%s)sV % \((?P<mapping_key>[^)]+)\) (?P<conversion_type>[diouxXeEfFgGcrs%]) s* ;(?=(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$)s+ %s(?=(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$)zNo result set to fetch fromc �, � e Zd ZdZd� Zd� Zed� � Zy)�_ParamSubstitutorz4 Substitutes parameters into SQL statement. c � � || _ d| _ y �Nr )�params�index)�selfr s �m/opt/hc_python/lib64/python3.12/site-packages/../../../lib/python3.12/site-packages/mysql/connector/cursor.py�__init__z_ParamSubstitutor.__init__C s � ������ � c � � | j }| xj dz c_ t | j | � S # t $ r t j d� �w xY w)Nr z+Not enough parameters for the SQL statement)r �bytesr � IndexErrorr �ProgrammingError)r �matchobjr s r �__call__z_ParamSubstitutor.__call__G sV � �� � ��� � �a�� � ?�����U�+�,�,��� ?��)�)�=�?� ?� ?�s �; �Ac �F � t | j � | j z S )z8Returns number of parameters remaining to be substituted)�lenr r �r s r � remainingz_ParamSubstitutor.remainingP s � � �4�;�;��$�*�*�,�,r N)�__name__� __module__�__qualname__�__doc__r r �propertyr � r r r r ? s% � ���?� �-� �-r r c �p �� �fd�}t j |t r| j d� � S | � S )ah >>> _bytestr_format_dict(b'%(a)s', {b'a': b'foobar'}) b'foobar >>> _bytestr_format_dict(b'%%(a)s', {b'a': b'foobar'}) b'%%(a)s' >>> _bytestr_format_dict(b'%%%(a)s', {b'a': b'foobar'}) b'%%foobar' >>> _bytestr_format_dict(b'%(x)s %(y)s', ... {b'x': b'x=%(y)s', b'y': b'y=%(x)s'}) b'x=%(y)s y=%(x)s' c � �� d }| j � }|d dk( rd}|d dk( r$t r|d j d� n|d }�| }|�t dj |d � � �t r|j d� S |S )N�conversion_type� %� s�mapping_key�utf-8z Unsupported conversion_type: {0})� groupdictr �encode� ValueError�format�decode)r �value�groups�key� value_dicts �r �replacez%_bytestr_format_dict.<locals>.replaceb s� �� ����#�#�%���#�$��,��E��#�$��,�� ��'�.�.�w�7�$�]�3� ��s�O�E��=�� � &��v�.?�'@� A�C� C�(+�u�|�|�G�$�6��6r r( )�RE_PY_MAPPING_PARAM�subr r- )�bytestrr1 r2 s ` r �_bytestr_format_dictr6 V s= �� �7� �"�"�7�&)� -4�N�N�7�,C� 8� 8�/6�8� 8r c � � � e Zd ZdZdZ� fd�Zdd�Zd� Zdd�Zd� Z d� Z dd �Zd � Zd� Z d� Zdd �Zdd�Zed� � Zed� � Zed� � Z� xZS )� CursorBasez� Base for defining MySQLCursor. This class is a skeleton and defines methods and members as required for the Python Database API Specification v2.0. It's better to inherite from MySQLCursor. Fc �b �� d | _ d| _ d | _ d| _ t t | � � y )N���r )�_description� _rowcount�_last_insert_id� arraysize�superr8 r �r � __class__s �r r zCursorBase.__init__} s. �� � ������#������ �j�$�(�*r c � � y)a Calls a stored procedue with the given arguments The arguments will be set during this session, meaning they will be called like _<procname>__arg<nr> where <nr> is an enumeration (+1) of the arguments. Coding Example: 1) Definining the Stored Routine in MySQL: CREATE PROCEDURE multiply(IN pFac1 INT, IN pFac2 INT, OUT pProd INT) BEGIN SET pProd := pFac1 * pFac2; END 2) Executing in Python: args = (5,5,0) # 0 is to hold pprod cursor.callproc('multiply', args) print(cursor.fetchone()) Does not return a value, but a result set will be available when the CALL-statement execute successfully. Raises exceptions when something is wrong. Nr! )r �procname�argss r �callproczCursorBase.callproc� s � �. r c � � y)zClose the cursor.Nr! r s r �closezCursorBase.close� � � �r c � � y)� Executes the given operation Executes the given operation substituting any markers with the given parameters. For example, getting all rows where id is 5: cursor.execute("SELECT * FROM t1 WHERE id = %s", (5,)) The multi argument should be set to True when executing multiple statements in one operation. If not set and multiple results are found, an InterfaceError will be raised. If warnings where generated, and connection.get_warnings is True, then self._warnings will be a list containing these warnings. Returns an iterator when multi is True, otherwise None. Nr! )r � operationr �multis r �executezCursorBase.execute� s � �$ r c � � y)a� Execute the given operation multiple times The executemany() method will execute the operation iterating over the list of parameters in seq_params. Example: Inserting 3 new employees and their phone number data = [ ('Jane','555-001'), ('Joe', '555-001'), ('John', '555-003') ] stmt = "INSERT INTO employees (name, phone) VALUES ('%s','%s')" cursor.executemany(stmt, data) INSERT statements are optimized by batching the data, that is using the MySQL multiple rows syntax. Results are discarded. If they are needed, consider looping over data using the execute() method. Nr! )r rK � seqparamss r �executemanyzCursorBase.executemany� s � �, r c � � y��QReturns next row of a query result set Returns a tuple or None. Nr! r s r �fetchonezCursorBase.fetchone� � � � r c � � y)a Returns the next set of rows of a query result, returning a list of tuples. When no more rows are available, it returns an empty list. The number of rows returned can be specified using the size argument, which defaults to one Nr! )r �sizes r � fetchmanyzCursorBase.fetchmany� s � � r c � � y)zRReturns all rows of a query result set Returns a list of tuples. Nr! r s r �fetchallzCursorBase.fetchall� rU r c � � y�zNot Implemented.Nr! r s r �nextsetzCursorBase.nextset� rH r c � � yr\ r! )r �sizess r � setinputsizeszCursorBase.setinputsizes� rH r c � � yr\ r! )r rW �columns r � setoutputsizezCursorBase.setoutputsize� rH r c � � y)�Reset the cursor to defaultNr! �r �frees r �resetzCursorBase.reset� rH r c � � | j S )a� Returns description of columns in a result This property returns a list of tuples describing the columns in in a result set. A tuple is described as follows:: (column_name, type, None, None, None, None, null_ok, column_flags) # Addition to PEP-249 specs Returns a list of tuples. )r; r s r �descriptionzCursorBase.description� s � �$ � � � r c � � | j S )a Returns the number of rows produced or affected This property returns the number of rows produced by queries such as a SELECT, or affected rows when executing DML statements like INSERT or UPDATE. Note that for non-buffered cursors it is impossible to know the number of rows produced before having fetched them all. For those, the number of rows will be -1 right after execution, and incremented when fetching rows. Returns an integer. )r<