HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python38/lib/python3.8/site-packages/pymysql/tests/__pycache__/test_basic.cpython-38.pyc
U

s_�We8�@s�ddlZddlZddlZddlZddlmZddlmZddlZddl	m
Z
ddlmZdddgZ
Gd	d�de
j�ZGd
d�de
j�ZGdd�de
j�ZdS)�N)�SkipTest)�util)�base)�ProgrammingError�TestConversion�
TestCursor�TestBulkInsertsc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)rcCs�|jd}|��}|�d��z�dddddd	d
�|j�t�ddd�t�d
ddddd�t�dd�t�dd�t�	�f}|�d|�|�d�|�
�}|�t�
d�|d�|�|dd�|dd��|�t�dd|djd|dj�|d�|�tj|ddd��|d�|�d�|�ddgd�|�d�|�
�}|�tdgd�|�|�d�ttttfD]H}|�d�|ddg�}|�d |f�|��}|�d!|�|�d��qnW5|�d�XdS)"z test every data type rz�create table test_datatypes (b bit, i int, l bigint, f real, s varchar(32), u varchar(32), bb blob, d date, dt datetime, ts timestamp, td time, t time, st datetime)zdrop table test_datatypesT���l2}rg������@z
hello'" worldu
Españolzbinarydatai��i�����-�9��� zeinsert into test_datatypes (b,i,l,f,s,u,bb,d,dt,td,t,st) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)z6select b,i,l,f,s,u,bb,d,dt,td,t,st from test_datatypes��
�<���Nzdelete from test_datatypes�z>insert into test_datatypes (i, l) values (2,4), (6,8), (10,12)z5select l from test_datatypes where i in %s order by i))�)�)�connections�cursor�execute�encode�charset�datetime�date�	timedelta�time�	localtime�fetchone�assertEqualr�int2byte�hour�minute�tuple�list�set�	frozenset�fetchall)�self�conn�c�v�rZseq_type�seq�r4�I/opt/alt/python38/lib/python3.8/site-packages/pymysql/tests/test_basic.py�test_datatypess4

R
0"



zTestConversion.test_datatypesc	Cs`|jd}|��}|�d�z2|�ddddd��|�d	�|�d
|���W5|�d�XdS)z test dict escaping rz8create table test_dict (a integer, b integer, c integer)�drop table test_dictz:insert into test_dict (a,b,c) values (%(a)s, %(b)s, %(c)s)rr
�)�a�br0zselect a,b,c from test_dict)rr
r8N�rrrr%r$�r.r/r0r4r4r5�	test_dict:s


zTestConversion.test_dictc	Cs^|jd}|��}|�d�d}z,|�d|�|�d�|�|f|���W5|�d�XdS)Nrzcreate table test_dict (a text)zI am a test stringr7�%insert into test_dict (a) values (%s)�select a from test_dictr;�r.r/r0Z
test_valuer4r4r5�test_stringFs


zTestConversion.test_stringc	Cs^|jd}|��}|�d�d}z,|�d|�|�d�|�|f|���W5|�d�XdS)Nrz"create table test_dict (a integer)i90r7r>r?r;r@r4r4r5�test_integerRs


zTestConversion.test_integerc	Csptttd��d�}|jd}|�|dd�|���2}|�d|f�|�d�|�||��d�W5QRXdS)	ztest binary data�rr�	test_blobzcreate table test_blob (b blob)z%insert into test_blob (b) values (%s)zselect b from test_blobN)	�bytes�	bytearray�ranger�safe_create_tablerrr%r$)r.�datar/r0r4r4r5rD^s
�

zTestConversion.test_blobcCsJ|jd}|��}|�d�|�d|���|�d�|�d|���dS)z' test conversion of null, empty string rzselect null,'')N�zselect '',null)rJNNr;r<r4r4r5�test_untypedjs


zTestConversion.test_untypedcCs�|jd}|��}|�d�|�t�dd�t�dd�t�ddd�t�dd�t�dd�t�ddd�t�dd�f|���dS)z test timedelta conversion rz�select time('12:30'), time('23:12:59'), time('23:12:59.05100'), time('-12:30'), time('-23:12:59'), time('-23:12:59.05100'), time('-00:30')iȯi{Fi8�iN)rrrr%rr!r$r<r4r4r5�test_timedeltass


��zTestConversion.test_timedeltac	Cs�|jd}|�|d�std��|��}t�ddddddd�}|�d	�z0|�dd|f�|�d
�|�|f|���W5|�d
�XdS)z( test datetime conversion w microsecondsr)rrrz,target backend does not support microsecondsi��r�	i:�z3create table test_datetime (id int, ts datetime(6))zdrop table test_datetimez)insert into test_datetime values (%s, %s)rzselect ts from test_datetimeN)r�mysql_server_isrrrrr%r$)r.r/r0�dtr4r4r5�test_datetime_microseconds�s

�
z)TestConversion.test_datetime_microsecondsN)�__name__�
__module__�__qualname__r6r=rArBrDrKrLrQr4r4r4r5rs'	c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rc	CsT|jd}|��}|�d�z&d}|�d|f�|�d|���W5|�d�XdS)z  test a fetchone() with no rows rz$create table test_nr (b varchar(32))zdrop table test_nr�pymysqlz#insert into test_nr (b) values (%s)Nr;)r.r/r0rIr4r4r5�test_fetch_no_result�s

zTestCursor.test_fetch_no_resultc	Csz|jd}|��}zV|�d�tdd�D]}|�d|f�q(|�d�|��\}|�ttdd��|�W5|�d�XdS)z test aggregate functions rzdrop table test_aggregatesz(create table test_aggregates (i integer)rz+insert into test_aggregates (i) values (%s)z"select sum(i) from test_aggregatesN)rrrrGr$r%�sum)r.r/r0�ir2r4r4r5�test_aggregates�s



zTestCursor.test_aggregatescCsb|jd}|��}|�|dd�|�d�|�d�|�dd�|�dgt|����|��d	S)
z test a single tuple rZmystuffz-create table mystuff (id integer primary key)z#insert into mystuff (id) values (1)z#insert into mystuff (id) values (2)z%select id from mystuff where id in %s)�rrZN)rrrHrr%r*r-�closer<r4r4r5�test_single_tuple�s
�

zTestCursor.test_single_tuplecCs�|jd��}d|d<tjf|�}|�|d�s6td��|�|dd�|��}d}|�d	|f�|�d
�|�	�d}|�
t�|�t�|��|�d|f�|�	�d}|�
t�|�t�|��dS)Nr�utf8mb4r)rr
rz*JSON type is not supported on MySQL <= 5.6�	test_jsonz]create table test_json (
    id int not null,
    json JSON not null,
    primary key (id)
);u{"hello": "こんにちは"}z2INSERT INTO test_json (id, `json`) values (42, %s)z,SELECT `json` from `test_json` WHERE `id`=42zSELECT CAST(%s AS JSON) AS x)
Z	databases�copyrU�connectrOrrHrrr$r%�json�loads)r.�argsr/�curZjson_str�resr4r4r5r^�s
zTestCursor.test_jsonN)rRrSrTrVrYr\r^r4r4r4r5r�s6
csTeZdZejjZ�fdd�Zdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
�ZS)rcs<tt|���|jd|_}|�|j�}|�|dd�dS)NrZ
bulkinsertz]CREATE TABLE bulkinsert
(
id int(11),
name char(20),
age int,
height int,
PRIMARY KEY (id)
)
)�superr�setUprr/r�cursor_typerHr<��	__class__r4r5rgszTestBulkInserts.setUpcCs<|jd}|��}|�d�|��}|�t|�t|��dS)Nrz,SELECT id, name, age, height from bulkinsert)rrrr-r%�sorted)r.rIr/r�resultr4r4r5�_verify_records!s


zTestBulkInserts._verify_recordscCsR|jd}|��}dddg}|�d|�|�|jtd��|�d�|�|�dS)Nr�rZbob��{�rZjim�8r�r
Zfred�d��Cinsert into bulkinsert (id, name, age, height) values (%s,%s,%s,%s)siinsert into bulkinsert (id, name, age, height) values (0,'bob',21,123),(1,'jim',56,45),(2,'fred',100,180)�commit)rr�executemanyr%�_last_executedrFrrm�r.r/rrIr4r4r5�test_bulk_insert(s

���
z TestBulkInserts.test_bulk_insertcCsV|jd}|��}dddg}|�d|�|�|j��td��|�d�|�|�dS)NrrnrqrszJinsert
into bulkinsert (id, name,
age, height)
values (%s,
%s , %s,
%s )
 sxinsert
into bulkinsert (id, name,
age, height)
values (0,
'bob' , 21,
123 ),(1,
'jim' , 56,
45 ),(2,
'fred' , 100,
180 )rw�	rrrxr%ry�striprFrrmrzr4r4r5�$test_bulk_insert_multiline_statement6s

�

z4TestBulkInserts.test_bulk_insert_multiline_statementcCs<|jd}|��}dg}|�d|�|�d�|�|�dS)Nrrnrvrw)rrrxrrmrzr4r4r5�test_bulk_insert_single_recordNs
�
z.TestBulkInserts.test_bulk_insert_single_recordcCsV|jd}|��}dddg}|�d|�|�|j��td��|�d�|�|�dS)	z4executemany should work with "insert ... on update" rrnrqrsztinsert
into bulkinsert (id, name,
age, height)
values (%s,
%s , %s,
%s ) on duplicate key update
age = values(age)
 s�insert
into bulkinsert (id, name,
age, height)
values (0,
'bob' , 21,
123 ),(1,
'jim' , 56,
45 ),(2,
'fred' , 100,
180 ) on duplicate key update
age = values(age)rwNr|rzr4r4r5�test_issue_288Ws

�
zTestBulkInserts.test_issue_288c	Cs�|jd}|��}tjdd��}t�d�|�d�W5QRX|�t|�d�|�|djt	j
�dt|dj�kr�|�
dt|dj�f�dS)	NrT)�record�alwaysz$drop table if exists no_exists_tablerZno_exists_tablez'no_exists_table' not in %s)rr�warnings�catch_warnings�simplefilterrr%�len�categoryrU�Warning�str�messageZfail)r.Zconrd�wsr4r4r5�
test_warningsrs

zTestBulkInserts.test_warnings)rRrSrTrU�cursors�
DictCursorrhrgrmr{r~rr�r��
__classcell__r4r4rir5rs	)rrar"r�Z	unittest2rrUrZpymysql.cursorsZ
pymysql.testsrZpymysql.errr�__all__ZPyMySQLTestCaserrrr4r4r4r5�<module>s
w