1
+ import datetime
2
+ from decimal import Decimal
1
3
from enum import Enum
2
4
3
5
import pytest
@@ -33,18 +35,33 @@ async def test_dict_cursor(connection):
33
35
async def test_insert (connection ):
34
36
async with connection .cursor (cursor = DictCursor ) as cursor :
35
37
rows = await cursor .execute (
36
- """INSERT INTO test.asyncmy(id,`decimal`, date, datetime, `float`, string, `tinyint`) VALUES (%s,%s,%s,%s,%s,%s,%s)""" ,
38
+ """INSERT INTO test.asyncmy(id,`decimal`, date, datetime, time, `float`, string, `tinyint`) VALUES (%s, %s,%s,%s,%s,%s,%s,%s)""" ,
37
39
(
38
- - 1 ,
40
+ 1 ,
39
41
1 ,
40
42
"2020-08-08" ,
41
43
"2020-08-08 00:00:00" ,
44
+ "00:00:00" ,
42
45
1 ,
43
46
"1" ,
44
47
1 ,
45
48
),
46
49
)
47
50
assert rows == 1
51
+ await cursor .execute ("select * from test.asyncmy where id = %s" , (cursor .lastrowid ,))
52
+ result = await cursor .fetchall ()
53
+ assert result == [
54
+ {
55
+ "id" : 1 ,
56
+ "decimal" : Decimal ("1.00" ),
57
+ "date" : datetime .date (2020 , 8 , 8 ),
58
+ "datetime" : datetime .datetime (2020 , 8 , 8 , 0 , 0 ),
59
+ "time" : datetime .time .fromisoformat ("00:00" ),
60
+ "float" : 1.0 ,
61
+ "string" : "1" ,
62
+ "tinyint" : 1 ,
63
+ }
64
+ ]
48
65
49
66
50
67
@pytest .mark .asyncio
@@ -58,12 +75,13 @@ async def test_delete(connection):
58
75
async def test_executemany (connection ):
59
76
async with connection .cursor (cursor = DictCursor ) as cursor :
60
77
rows = await cursor .executemany (
61
- """INSERT INTO test.asyncmy(`decimal`, date, datetime, `float`, string, `tinyint`) VALUES (%s,%s,%s,%s,%s,%s)""" ,
78
+ """INSERT INTO test.asyncmy(`decimal`, date, datetime, time, `float`, string, `tinyint`) VALUES (%s, %s,%s,%s,%s,%s,%s)""" ,
62
79
[
63
80
(
64
81
1 ,
65
82
"2020-08-08" ,
66
83
"2020-08-08 00:00:00" ,
84
+ "00:00:00" ,
67
85
1 ,
68
86
"1" ,
69
87
1 ,
@@ -72,6 +90,7 @@ async def test_executemany(connection):
72
90
1 ,
73
91
"2020-08-08" ,
74
92
"2020-08-08 00:00:00" ,
93
+ "00:00:00" ,
75
94
1 ,
76
95
"1" ,
77
96
1 ,
@@ -105,12 +124,13 @@ class EnumValue(str, Enum):
105
124
async def test_insert_enum (connection ):
106
125
async with connection .cursor (cursor = DictCursor ) as cursor :
107
126
rows = await cursor .execute (
108
- """INSERT INTO test.asyncmy(id,`decimal`, date, datetime, `float`, string, `tinyint`) VALUES (%s,%s,%s,%s,%s,%s,%s)""" ,
127
+ """INSERT INTO test.asyncmy(id, `decimal`, date, datetime, time, `float`, string, `tinyint`) VALUES (%s, %s,%s,%s,%s,%s,%s,%s)""" ,
109
128
(
110
129
- 1 ,
111
130
1 ,
112
131
"2020-08-08" ,
113
132
"2020-08-08 00:00:00" ,
133
+ "00:00:00" ,
114
134
1 ,
115
135
EnumValue .VALUE ,
116
136
1 ,
0 commit comments