@@ -6,10 +6,10 @@ DBInterface.close!(conn)
6
6
# load host/user + options from file
7
7
conn = DBInterface. connect (MySQL. Connection, " " , " " , " " ; option_file= " my.ini" )
8
8
9
- DBInterface. execute! (conn, " DROP DATABASE if exists mysqltest" )
10
- DBInterface. execute! (conn, " CREATE DATABASE mysqltest" )
11
- DBInterface. execute! (conn, " use mysqltest" )
12
- DBInterface. execute! (conn, """ CREATE TABLE Employee
9
+ DBInterface. execute (conn, " DROP DATABASE if exists mysqltest" )
10
+ DBInterface. execute (conn, " CREATE DATABASE mysqltest" )
11
+ DBInterface. execute (conn, " use mysqltest" )
12
+ DBInterface. execute (conn, """ CREATE TABLE Employee
13
13
(
14
14
ID INT NOT NULL AUTO_INCREMENT,
15
15
OfficeNo TINYINT,
@@ -30,7 +30,7 @@ DBInterface.execute!(conn, """CREATE TABLE Employee
30
30
PRIMARY KEY (ID)
31
31
);""" )
32
32
33
- DBInterface. execute! (conn, """ INSERT INTO Employee (OfficeNo, DeptNo, EmpNo, Wage, Salary, Rate, LunchTime, JoinDate, LastLogin, LastLogin2, Initial, Name, Photo, JobType, Senior)
33
+ DBInterface. execute (conn, """ INSERT INTO Employee (OfficeNo, DeptNo, EmpNo, Wage, Salary, Rate, LunchTime, JoinDate, LastLogin, LastLogin2, Initial, Name, Photo, JobType, Senior)
34
34
VALUES
35
35
(1, 2, 1301, 3.14, 10000.50, 1.001, '12:00:00', '2015-8-3', '2015-9-5 12:31:30', '2015-9-5 12:31:30', 'A', 'John', 'abc', 'HR', b'1'),
36
36
(1, 2, 1422, 3.14, 20000.25, 2.002, '13:00:00', '2015-8-4', '2015-10-12 13:12:14', '2015-10-12 13:12:14', 'B', 'Tom', 'def', 'HR', b'1'),
@@ -57,7 +57,7 @@ expected = (
57
57
Senior = Union{Missing, MySQL. API. Bit}[MySQL. API. Bit (1 ), MySQL. API. Bit (1 ), MySQL. API. Bit (0 ), MySQL. API. Bit (1 )],
58
58
)
59
59
60
- cursor = DBInterface. execute! (conn, " select * from Employee" )
60
+ cursor = DBInterface. execute (conn, " select * from Employee" )
61
61
@test DBInterface. lastrowid (cursor) == 1
62
62
@test eltype (cursor) == MySQL. TextRow
63
63
@test Tables. istable (cursor)
@@ -75,14 +75,14 @@ for (i, prop) in enumerate(propertynames(row))
75
75
@test getproperty (row, prop) == row[prop] == row[i] == expected[prop][1 ]
76
76
end
77
77
78
- res = DBInterface. execute! (conn, " select * from Employee" ) |> columntable
78
+ res = DBInterface. execute (conn, " select * from Employee" ) |> columntable
79
79
@test length (res) == 16
80
80
@test length (res[1 ]) == 4
81
81
@test res == expected
82
82
83
83
# as a prepared statement
84
84
stmt = DBInterface. prepare (conn, " select * from Employee" )
85
- cursor = DBInterface. execute! (stmt)
85
+ cursor = DBInterface. execute (stmt)
86
86
@test DBInterface. lastrowid (cursor) == 1
87
87
@test eltype (cursor) == MySQL. Row
88
88
@test Tables. istable (cursor)
@@ -100,15 +100,15 @@ for (i, prop) in enumerate(propertynames(row))
100
100
@test getproperty (row, prop) == row[prop] == row[i] == expected[prop][1 ]
101
101
end
102
102
103
- res = DBInterface. execute! (stmt) |> columntable
103
+ res = DBInterface. execute (stmt) |> columntable
104
104
@test length (res) == 16
105
105
@test length (res[1 ]) == 4
106
106
@test res == expected
107
107
108
108
@test DBInterface. close! (stmt) === nothing
109
109
110
110
# insert null row
111
- DBInterface. execute! (conn, " INSERT INTO Employee () VALUES ();" )
111
+ DBInterface. execute (conn, " INSERT INTO Employee () VALUES ();" )
112
112
for i = 1 : length (expected)
113
113
if i == 1
114
114
push! (expected[i], 5 )
@@ -118,7 +118,7 @@ for i = 1:length(expected)
118
118
end
119
119
end
120
120
121
- res = DBInterface. execute! (conn, " select * from Employee" ) |> columntable
121
+ res = DBInterface. execute (conn, " select * from Employee" ) |> columntable
122
122
@test length (res) == 16
123
123
@test length (res[1 ]) == 5
124
124
for i = 1 : length (expected)
@@ -128,7 +128,7 @@ for i = 1:length(expected)
128
128
end
129
129
130
130
stmt = DBInterface. prepare (conn, " select * from Employee" )
131
- res = DBInterface. execute! (stmt) |> columntable
131
+ res = DBInterface. execute (stmt) |> columntable
132
132
DBInterface. close! (stmt)
133
133
@test length (res) == 16
134
134
@test length (res[1 ]) == 5
@@ -139,7 +139,7 @@ for i = 1:length(expected)
139
139
end
140
140
141
141
# now test insert/parameter binding
142
- DBInterface. execute! (conn, " DELETE FROM Employee" )
142
+ DBInterface. execute (conn, " DELETE FROM Employee" )
143
143
for i = 1 : length (expected)
144
144
if i != 11
145
145
pop! (expected[i])
@@ -150,10 +150,10 @@ stmt = DBInterface.prepare(conn,
150
150
" INSERT INTO Employee (OfficeNo, DeptNo, EmpNo, Wage, Salary, Rate, LunchTime, JoinDate, LastLogin, LastLogin2, Initial, Name, Photo, JobType, Senior)
151
151
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" )
152
152
153
- DBInterface. executemany! (stmt, Base. structdiff (expected, NamedTuple{(:ID ,)})... )
153
+ DBInterface. executemany (stmt, Base. structdiff (expected, NamedTuple{(:ID ,)}))
154
154
155
155
stmt2 = DBInterface. prepare (conn, " select * from Employee" )
156
- res = DBInterface. execute! (stmt2) |> columntable
156
+ res = DBInterface. execute (stmt2) |> columntable
157
157
DBInterface. close! (stmt2)
158
158
@test length (res) == 16
159
159
@test length (res[1 ]) == 4
@@ -163,11 +163,11 @@ for i = 1:length(expected)
163
163
end
164
164
end
165
165
166
- DBInterface. execute! (stmt, missing , missing , missing , missing , missing , missing , missing , missing , missing , DateTime (" 2015-09-05T12:31:30" ), missing , missing , missing , missing , missing )
166
+ DBInterface. execute (stmt, [ missing , missing , missing , missing , missing , missing , missing , missing , missing , DateTime (" 2015-09-05T12:31:30" ), missing , missing , missing , missing , missing ] )
167
167
DBInterface. close! (stmt)
168
168
169
169
stmt = DBInterface. prepare (conn, " select * from Employee" )
170
- res = DBInterface. execute! (stmt) |> columntable
170
+ res = DBInterface. execute (stmt) |> columntable
171
171
DBInterface. close! (stmt)
172
172
for i = 1 : length (expected)
173
173
if i != 11 && i != 1
@@ -176,20 +176,20 @@ for i = 1:length(expected)
176
176
end
177
177
178
178
# mysql_use_result
179
- res = DBInterface. execute! (conn, " select DeptNo, OfficeNo from Employee" ; mysql_store_result= false ) |> columntable
179
+ res = DBInterface. execute (conn, " select DeptNo, OfficeNo from Employee" ; mysql_store_result= false ) |> columntable
180
180
@test length (res) == 2
181
181
@test length (res[1 ]) == 5
182
182
@test isequal (res. OfficeNo, [1 , 1 , 1 , 1 , missing ])
183
183
184
184
stmt = DBInterface. prepare (conn, " select DeptNo, OfficeNo from Employee" )
185
- res = DBInterface. execute! (stmt; mysql_store_result= false ) |> columntable
185
+ res = DBInterface. execute (stmt; mysql_store_result= false ) |> columntable
186
186
DBInterface. close! (stmt)
187
187
@test length (res) == 2
188
188
@test length (res[1 ]) == 5
189
189
@test isequal (res. OfficeNo, [1 , 1 , 1 , 1 , missing ])
190
190
191
191
stmt = DBInterface. prepare (conn, " select DeptNo, OfficeNo from Employee where OfficeNo = ?" )
192
- res = DBInterface. execute! (stmt, 1 ; mysql_store_result= false ) |> columntable
192
+ res = DBInterface. execute (stmt, 1 ; mysql_store_result= false ) |> columntable
193
193
DBInterface. close! (stmt)
194
194
@test length (res) == 2
195
195
@test length (res[1 ]) == 4
0 commit comments