@@ -29,6 +29,11 @@ func (c *Conn) Unleak() {
29
29
c .connectionID = ""
30
30
}
31
31
32
+ // Begin starts a transaction. The default isolation level is dependent on the driver.
33
+ func (c * Conn ) Begin (opts * stdSql.TxOptions ) (* Tx , error ) {
34
+ return c .BeginTx (context .Background (), opts )
35
+ }
36
+
32
37
// BeginTx starts a transaction.
33
38
//
34
39
// The provided context is used until the transaction is committed or rolled back.
@@ -63,6 +68,12 @@ func (c *Conn) Close() error {
63
68
return nil
64
69
}
65
70
71
+ // Exec executes a query without returning any rows.
72
+ // The args are for any placeholder parameters in the query.
73
+ func (c * Conn ) Exec (query string , args ... interface {}) (stdSql.Result , error ) {
74
+ return c .ExecContext (context .Background (), query , args ... )
75
+ }
76
+
66
77
// ExecContext executes a query without returning any rows.
67
78
// The args are for any placeholder parameters in the query.
68
79
func (c * Conn ) ExecContext (ctx context.Context , query string , args ... interface {}) (stdSql.Result , error ) {
@@ -106,6 +117,11 @@ func (c *Conn) ExecContext(ctx context.Context, query string, args ...interface{
106
117
}
107
118
}
108
119
120
+ // Ping verifies a connection to the database is still alive.
121
+ func (c * Conn ) Ping () error {
122
+ return c .PingContext (context .Background ())
123
+ }
124
+
109
125
// PingContext verifies the connection to the database is still alive.
110
126
func (c * Conn ) PingContext (ctx context.Context ) error {
111
127
@@ -141,6 +157,15 @@ func (c *Conn) PingContext(ctx context.Context) error {
141
157
}
142
158
}
143
159
160
+ // Prepare creates a prepared statement for later queries or executions.
161
+ // Multiple queries or executions may be run concurrently from the
162
+ // returned statement.
163
+ // The caller must call the statement's Close method
164
+ // when the statement is no longer needed.
165
+ func (c * Conn ) Prepare (query string ) (* Stmt , error ) {
166
+ return c .PrepareContext (context .Background (), query )
167
+ }
168
+
144
169
// PrepareContext creates a prepared statement for later queries or executions.
145
170
// Multiple queries or executions may be run concurrently from the
146
171
// returned statement.
@@ -191,6 +216,12 @@ func (c *Conn) PrepareContext(ctx context.Context, query string) (*Stmt, error)
191
216
192
217
}
193
218
219
+ // Query executes a query that returns rows, typically a SELECT.
220
+ // The args are for any placeholder parameters in the query.
221
+ func (c * Conn ) Query (query string , args ... interface {}) (* stdSql.Rows , error ) {
222
+ return c .QueryContext (context .Background (), query , args ... )
223
+ }
224
+
194
225
// QueryContext executes a query that returns rows, typically a SELECT.
195
226
// The args are for any placeholder parameters in the query.
196
227
func (c * Conn ) QueryContext (ctx context.Context , query string , args ... interface {}) (* stdSql.Rows , error ) {
@@ -206,6 +237,14 @@ func (c *Conn) QueryContext(ctx context.Context, query string, args ...interface
206
237
return c .conn .QueryContext (ctx , query , args ... )
207
238
}
208
239
240
+ // QueryRow executes a query that is expected to return at most one row.
241
+ // QueryRow always returns a non-nil value. Errors are deferred until
242
+ // Row's Scan method is called.
243
+ // If the query selects no rows, the *Row's Scan will return ErrNoRows.
244
+ // Otherwise, the *Row's Scan scans the first selected row and discards
245
+ // the rest.
246
+ func (c * Conn ) QueryRow (query string , args ... interface {}) * stdSql.Row {
247
+ return c .QueryRowContext (context .Background (), query , args ... )
209
248
}
210
249
211
250
// QueryRowContext executes a query that is expected to return at most one row.
@@ -223,6 +262,5 @@ func (c *Conn) QueryRowContext(ctx context.Context, query string, args ...interf
223
262
}
224
263
}()
225
264
226
- row := c .conn .QueryRowContext (ctx , query , args ... )
227
- return row
265
+ return c .conn .QueryRowContext (ctx , query , args ... )
228
266
}
0 commit comments