MOON
Server: Apache
System: Linux server30c.hostingraja.org 3.10.0-962.3.2.lve1.5.63.el7.x86_64 #1 SMP Fri Oct 8 12:03:35 UTC 2021 x86_64
User: jibhires (1887)
PHP: 8.1.30
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, allow_url_fopen, symlink, escapeshellcmd, pcntl_exec
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�assertEqualrZint2byteZhourZminute�tuple�list�set�	frozenset�fetchall)�self�conn�c�v�rZseq_type�seq�r1�/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�br-zselect a,b,c from test_dict)rr
r5N�rrrr%r$�r+r,r-r1r1r2�	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 stringr4�%insert into test_dict (a) values (%s)�select a from test_dictr8�r+r,r-Z
test_valuer1r1r2�test_stringFs


zTestConversion.test_stringc	Cs^|jd}|��}|�d�d}z,|�d|�|�d�|�|f|���W5|�d�XdS)Nrz"create table test_dict (a integer)i90r4r;r<r8r=r1r1r2�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,r-r1r1r2rA^s
�

zTestConversion.test_blobcCsJ|jd}|��}|�d�|�d|���|�d�|�d|���dS)z' test conversion of null, empty string rzselect null,'')N�zselect '',null)rGNNr8r9r1r1r2�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$r9r1r1r2�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,r-Zdtr1r1r2�test_datetime_microseconds�s

�
z)TestConversion.test_datetime_microsecondsN)�__name__�
__module__�__qualname__r3r:r>r?rArHrIrMr1r1r1r2rs'	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)Nr8)r+r,r-rFr1r1r2�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)rrrrDr$r%�sum)r+r,r-�ir/r1r1r2�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)�rrVN)rrrErr%r'r*�closer9r1r1r2�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)NrZutf8mb4r)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�copyrQZconnectrLrrErrr$r%�json�loads)r+�argsr,�curZjson_str�resr1r1r2rY�s
zTestCursor.test_jsonN)rNrOrPrRrUrXrYr1r1r1r2r�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_typerEr9��	__class__r1r2raszTestBulkInserts.setUpcCs<|jd}|��}|�d�|��}|�t|�t|��dS)Nrz,SELECT id, name, age, height from bulkinsert)rrrr*r%�sorted)r+rFr,r�resultr1r1r2�_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_executedrCrrg�r+r,rrFr1r1r2�test_bulk_insert(s

���
z TestBulkInserts.test_bulk_insertcCsV|jd}|��}dddg}|�d|�|�|j��td��|�d�|�|�dS)NrrhrkrmzJinsert
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 )rq�	rrrrr%rs�striprCrrgrtr1r1r2�$test_bulk_insert_multiline_statement6s

�

z4TestBulkInserts.test_bulk_insert_multiline_statementcCs<|jd}|��}dg}|�d|�|�d�|�|�dS)Nrrhrprq)rrrrrrgrtr1r1r2�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" rrhrkrmztinsert
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)rqNrvrtr1r1r2�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�categoryrQ�Warning�str�messageZfail)r+Zconr^Zwsr1r1r2�
test_warningsrs

zTestBulkInserts.test_warnings)rNrOrPrQZcursorsZ
DictCursorrbrargrurxryrzr��
__classcell__r1r1rcr2rs	)rr[r"r}Z	unittest2rrQrZpymysql.cursorsZ
pymysql.testsrZpymysql.errr�__all__ZPyMySQLTestCaserrrr1r1r1r2�<module>s
w