You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

926 lines
26 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>driver - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package driver</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "database/sql/driver"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. </dl>
  58. </div>
  59. <!-- The package's Name is printed as title by the top-level template -->
  60. <div id="pkg-overview" class="toggleVisible">
  61. <div class="collapsed">
  62. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  63. </div>
  64. <div class="expanded">
  65. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  66. <p>
  67. Package driver defines interfaces to be implemented by database
  68. drivers as used by package sql.
  69. </p>
  70. <p>
  71. Most code should use package sql.
  72. </p>
  73. </div>
  74. </div>
  75. <div id="pkg-index" class="toggleVisible">
  76. <div class="collapsed">
  77. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  78. </div>
  79. <div class="expanded">
  80. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  81. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  82. <div id="manual-nav">
  83. <dl>
  84. <dd><a href="index.html#pkg-variables">Variables</a></dd>
  85. <dd><a href="index.html#IsScanValue">func IsScanValue(v interface{}) bool</a></dd>
  86. <dd><a href="index.html#IsValue">func IsValue(v interface{}) bool</a></dd>
  87. <dd><a href="index.html#ColumnConverter">type ColumnConverter</a></dd>
  88. <dd><a href="index.html#Conn">type Conn</a></dd>
  89. <dd><a href="index.html#Driver">type Driver</a></dd>
  90. <dd><a href="index.html#Execer">type Execer</a></dd>
  91. <dd><a href="index.html#NotNull">type NotNull</a></dd>
  92. <dd>&nbsp; &nbsp; <a href="index.html#NotNull.ConvertValue">func (n NotNull) ConvertValue(v interface{}) (Value, error)</a></dd>
  93. <dd><a href="index.html#Null">type Null</a></dd>
  94. <dd>&nbsp; &nbsp; <a href="index.html#Null.ConvertValue">func (n Null) ConvertValue(v interface{}) (Value, error)</a></dd>
  95. <dd><a href="index.html#Queryer">type Queryer</a></dd>
  96. <dd><a href="index.html#Result">type Result</a></dd>
  97. <dd><a href="index.html#Rows">type Rows</a></dd>
  98. <dd><a href="index.html#RowsAffected">type RowsAffected</a></dd>
  99. <dd>&nbsp; &nbsp; <a href="index.html#RowsAffected.LastInsertId">func (RowsAffected) LastInsertId() (int64, error)</a></dd>
  100. <dd>&nbsp; &nbsp; <a href="index.html#RowsAffected.RowsAffected">func (v RowsAffected) RowsAffected() (int64, error)</a></dd>
  101. <dd><a href="index.html#Stmt">type Stmt</a></dd>
  102. <dd><a href="index.html#Tx">type Tx</a></dd>
  103. <dd><a href="index.html#Value">type Value</a></dd>
  104. <dd><a href="index.html#ValueConverter">type ValueConverter</a></dd>
  105. <dd><a href="index.html#Valuer">type Valuer</a></dd>
  106. </dl>
  107. </div><!-- #manual-nav -->
  108. <h4>Package files</h4>
  109. <p>
  110. <span style="font-size:90%">
  111. <a href="http://localhost:6060/src/database/sql/driver/driver.go">driver.go</a>
  112. <a href="http://localhost:6060/src/database/sql/driver/types.go">types.go</a>
  113. </span>
  114. </p>
  115. </div><!-- .expanded -->
  116. </div><!-- #pkg-index -->
  117. <div id="pkg-callgraph" class="toggle" style="display: none">
  118. <div class="collapsed">
  119. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  120. </div> <!-- .expanded -->
  121. <div class="expanded">
  122. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  123. <p>
  124. In the call graph viewer below, each node
  125. is a function belonging to this package
  126. and its children are the functions it
  127. calls&mdash;perhaps dynamically.
  128. </p>
  129. <p>
  130. The root nodes are the entry points of the
  131. package: functions that may be called from
  132. outside the package.
  133. There may be non-exported or anonymous
  134. functions among them if they are called
  135. dynamically from another package.
  136. </p>
  137. <p>
  138. Click a node to visit that function's source code.
  139. From there you can visit its callers by
  140. clicking its declaring <code>func</code>
  141. token.
  142. </p>
  143. <p>
  144. Functions may be omitted if they were
  145. determined to be unreachable in the
  146. particular programs or tests that were
  147. analyzed.
  148. </p>
  149. <!-- Zero means show all package entry points. -->
  150. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  151. </div>
  152. </div> <!-- #pkg-callgraph -->
  153. <h2 id="pkg-variables">Variables</h2>
  154. <pre>var <span id="Bool">Bool</span> boolType</pre>
  155. <p>
  156. Bool is a ValueConverter that converts input values to bools.
  157. </p>
  158. <p>
  159. The conversion rules are:
  160. </p>
  161. <pre>- booleans are returned unchanged
  162. - for integer types,
  163. 1 is true
  164. 0 is false,
  165. other integers are an error
  166. - for strings and []byte, same rules as strconv.ParseBool
  167. - all other types are an error
  168. </pre>
  169. <pre>var <span id="DefaultParameterConverter">DefaultParameterConverter</span> defaultConverter</pre>
  170. <p>
  171. DefaultParameterConverter is the default implementation of
  172. ValueConverter that&#39;s used when a Stmt doesn&#39;t implement
  173. ColumnConverter.
  174. </p>
  175. <p>
  176. DefaultParameterConverter returns its argument directly if
  177. IsValue(arg). Otherwise, if the argument implements Valuer, its
  178. Value method is used to return a Value. As a fallback, the provided
  179. argument&#39;s underlying type is used to convert it to a Value:
  180. underlying integer types are converted to int64, floats to float64,
  181. and strings to []byte. If the argument is a nil pointer,
  182. ConvertValue returns a nil Value. If the argument is a non-nil
  183. pointer, it is dereferenced and ConvertValue is called
  184. recursively. Other types are an error.
  185. </p>
  186. <pre>var <span id="ErrBadConn">ErrBadConn</span> = <a href="../../../errors/index.html">errors</a>.<a href="../../../errors/index.html#New">New</a>(&#34;driver: bad connection&#34;)</pre>
  187. <p>
  188. ErrBadConn should be returned by a driver to signal to the sql
  189. package that a driver.Conn is in a bad state (such as the server
  190. having earlier closed the connection) and the sql package should
  191. retry on a new connection.
  192. </p>
  193. <p>
  194. To prevent duplicate operations, ErrBadConn should NOT be returned
  195. if there&#39;s a possibility that the database server might have
  196. performed the operation. Even if the server sends back an error,
  197. you shouldn&#39;t return ErrBadConn.
  198. </p>
  199. <pre>var <span id="ErrSkip">ErrSkip</span> = <a href="../../../errors/index.html">errors</a>.<a href="../../../errors/index.html#New">New</a>(&#34;driver: skip fast-path; continue as if unimplemented&#34;)</pre>
  200. <p>
  201. ErrSkip may be returned by some optional interfaces&#39; methods to
  202. indicate at runtime that the fast path is unavailable and the sql
  203. package should continue as if the optional interface was not
  204. implemented. ErrSkip is only supported where explicitly
  205. documented.
  206. </p>
  207. <pre>var <span id="Int32">Int32</span> int32Type</pre>
  208. <p>
  209. Int32 is a ValueConverter that converts input values to int64,
  210. respecting the limits of an int32 value.
  211. </p>
  212. <pre>var <span id="ResultNoRows">ResultNoRows</span> noRows</pre>
  213. <p>
  214. ResultNoRows is a pre-defined Result for drivers to return when a DDL
  215. command (such as a CREATE TABLE) succeeds. It returns an error for both
  216. LastInsertId and RowsAffected.
  217. </p>
  218. <pre>var <span id="String">String</span> stringType</pre>
  219. <p>
  220. String is a ValueConverter that converts its input to a string.
  221. If the value is already a string or []byte, it&#39;s unchanged.
  222. If the value is of another type, conversion to string is done
  223. with fmt.Sprintf(&#34;%v&#34;, v).
  224. </p>
  225. <h2 id="IsScanValue">func <a href="http://localhost:6060/src/database/sql/driver/types.go?s=5334:5370#L178">IsScanValue</a></h2>
  226. <pre>func IsScanValue(v interface{}) <a href="../../../builtin/index.html#bool">bool</a></pre>
  227. <p>
  228. IsScanValue reports whether v is a valid Value scan type.
  229. Unlike IsValue, IsScanValue does not permit the string type.
  230. </p>
  231. <h2 id="IsValue">func <a href="http://localhost:6060/src/database/sql/driver/types.go?s=5072:5104#L166">IsValue</a></h2>
  232. <pre>func IsValue(v interface{}) <a href="../../../builtin/index.html#bool">bool</a></pre>
  233. <p>
  234. IsValue reports whether v is a valid Value parameter type.
  235. Unlike IsScanValue, IsValue permits the string type.
  236. </p>
  237. <h2 id="ColumnConverter">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=4804:5087#L135">ColumnConverter</a></h2>
  238. <pre>type ColumnConverter interface {
  239. <span class="comment">// ColumnConverter returns a ValueConverter for the provided</span>
  240. <span class="comment">// column index. If the type of a specific column isn&#39;t known</span>
  241. <span class="comment">// or shouldn&#39;t be handled specially, DefaultValueConverter</span>
  242. <span class="comment">// can be returned.</span>
  243. ColumnConverter(idx <a href="../../../builtin/index.html#int">int</a>) <a href="index.html#ValueConverter">ValueConverter</a>
  244. }</pre>
  245. <p>
  246. ColumnConverter may be optionally implemented by Stmt if the
  247. statement is aware of its own columns&#39; types and can convert from
  248. any type to a driver Value.
  249. </p>
  250. <h2 id="Conn">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=2778:3359#L73">Conn</a></h2>
  251. <pre>type Conn interface {
  252. <span class="comment">// Prepare returns a prepared statement, bound to this connection.</span>
  253. Prepare(query <a href="../../../builtin/index.html#string">string</a>) (<a href="index.html#Stmt">Stmt</a>, <a href="../../../builtin/index.html#error">error</a>)
  254. <span class="comment">// Close invalidates and potentially stops any current</span>
  255. <span class="comment">// prepared statements and transactions, marking this</span>
  256. <span class="comment">// connection as no longer in use.</span>
  257. <span class="comment">//</span>
  258. <span class="comment">// Because the sql package maintains a free pool of</span>
  259. <span class="comment">// connections and only calls Close when there&#39;s a surplus of</span>
  260. <span class="comment">// idle connections, it shouldn&#39;t be necessary for drivers to</span>
  261. <span class="comment">// do their own connection caching.</span>
  262. Close() <a href="../../../builtin/index.html#error">error</a>
  263. <span class="comment">// Begin starts and returns a new transaction.</span>
  264. Begin() (<a href="index.html#Tx">Tx</a>, <a href="../../../builtin/index.html#error">error</a>)
  265. }</pre>
  266. <p>
  267. Conn is a connection to a database. It is not used concurrently
  268. by multiple goroutines.
  269. </p>
  270. <p>
  271. Conn is assumed to be stateful.
  272. </p>
  273. <h2 id="Driver">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=667:1088#L16">Driver</a></h2>
  274. <pre>type Driver interface {
  275. <span class="comment">// Open returns a new connection to the database.</span>
  276. <span class="comment">// The name is a string in a driver-specific format.</span>
  277. <span class="comment">//</span>
  278. <span class="comment">// Open may return a cached connection (one previously</span>
  279. <span class="comment">// closed), but doing so is unnecessary; the sql package</span>
  280. <span class="comment">// maintains a pool of idle connections for efficient re-use.</span>
  281. <span class="comment">//</span>
  282. <span class="comment">// The returned connection is only used by one goroutine at a</span>
  283. <span class="comment">// time.</span>
  284. Open(name <a href="../../../builtin/index.html#string">string</a>) (<a href="index.html#Conn">Conn</a>, <a href="../../../builtin/index.html#error">error</a>)
  285. }</pre>
  286. <p>
  287. Driver is the interface that must be implemented by a database
  288. driver.
  289. </p>
  290. <h2 id="Execer">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=2231:2306#L54">Execer</a></h2>
  291. <pre>type Execer interface {
  292. Exec(query <a href="../../../builtin/index.html#string">string</a>, args []<a href="index.html#Value">Value</a>) (<a href="index.html#Result">Result</a>, <a href="../../../builtin/index.html#error">error</a>)
  293. }</pre>
  294. <p>
  295. Execer is an optional interface that may be implemented by a Conn.
  296. </p>
  297. <p>
  298. If a Conn does not implement Execer, the sql package&#39;s DB.Exec will
  299. first prepare a query, execute the statement, and then close the
  300. statement.
  301. </p>
  302. <p>
  303. Exec may return ErrSkip.
  304. </p>
  305. <h2 id="NotNull">type <a href="http://localhost:6060/src/database/sql/driver/types.go?s=4734:4783#L153">NotNull</a></h2>
  306. <pre>type NotNull struct {
  307. Converter <a href="index.html#ValueConverter">ValueConverter</a>
  308. }</pre>
  309. <p>
  310. NotNull is a type that implements ValueConverter by disallowing nil
  311. values but otherwise delegating to another ValueConverter.
  312. </p>
  313. <h3 id="NotNull.ConvertValue">func (NotNull) <a href="http://localhost:6060/src/database/sql/driver/types.go?s=4785:4844#L157">ConvertValue</a></h3>
  314. <pre>func (n <a href="index.html#NotNull">NotNull</a>) ConvertValue(v interface{}) (<a href="index.html#Value">Value</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  315. <h2 id="Null">type <a href="http://localhost:6060/src/database/sql/driver/types.go?s=4419:4465#L140">Null</a></h2>
  316. <pre>type Null struct {
  317. Converter <a href="index.html#ValueConverter">ValueConverter</a>
  318. }</pre>
  319. <p>
  320. Null is a type that implements ValueConverter by allowing nil
  321. values but otherwise delegating to another ValueConverter.
  322. </p>
  323. <h3 id="Null.ConvertValue">func (Null) <a href="http://localhost:6060/src/database/sql/driver/types.go?s=4467:4523#L144">ConvertValue</a></h3>
  324. <pre>func (n <a href="index.html#Null">Null</a>) ConvertValue(v interface{}) (<a href="index.html#Value">Value</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  325. <h2 id="Queryer">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=2569:2644#L65">Queryer</a></h2>
  326. <pre>type Queryer interface {
  327. Query(query <a href="../../../builtin/index.html#string">string</a>, args []<a href="index.html#Value">Value</a>) (<a href="index.html#Rows">Rows</a>, <a href="../../../builtin/index.html#error">error</a>)
  328. }</pre>
  329. <p>
  330. Queryer is an optional interface that may be implemented by a Conn.
  331. </p>
  332. <p>
  333. If a Conn does not implement Queryer, the sql package&#39;s DB.Query will
  334. first prepare a query, execute the statement, and then close the
  335. statement.
  336. </p>
  337. <p>
  338. Query may return ErrSkip.
  339. </p>
  340. <h2 id="Result">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=3407:3693#L92">Result</a></h2>
  341. <pre>type Result interface {
  342. <span class="comment">// LastInsertId returns the database&#39;s auto-generated ID</span>
  343. <span class="comment">// after, for example, an INSERT into a table with primary</span>
  344. <span class="comment">// key.</span>
  345. LastInsertId() (<a href="../../../builtin/index.html#int64">int64</a>, <a href="../../../builtin/index.html#error">error</a>)
  346. <span class="comment">// RowsAffected returns the number of rows affected by the</span>
  347. <span class="comment">// query.</span>
  348. RowsAffected() (<a href="../../../builtin/index.html#int64">int64</a>, <a href="../../../builtin/index.html#error">error</a>)
  349. }</pre>
  350. <p>
  351. Result is the result of a query execution.
  352. </p>
  353. <h2 id="Rows">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=5146:5861#L144">Rows</a></h2>
  354. <pre>type Rows interface {
  355. <span class="comment">// Columns returns the names of the columns. The number of</span>
  356. <span class="comment">// columns of the result is inferred from the length of the</span>
  357. <span class="comment">// slice. If a particular column name isn&#39;t known, an empty</span>
  358. <span class="comment">// string should be returned for that entry.</span>
  359. Columns() []<a href="../../../builtin/index.html#string">string</a>
  360. <span class="comment">// Close closes the rows iterator.</span>
  361. Close() <a href="../../../builtin/index.html#error">error</a>
  362. <span class="comment">// Next is called to populate the next row of data into</span>
  363. <span class="comment">// the provided slice. The provided slice will be the same</span>
  364. <span class="comment">// size as the Columns() are wide.</span>
  365. <span class="comment">//</span>
  366. <span class="comment">// The dest slice may be populated only with</span>
  367. <span class="comment">// a driver Value type, but excluding string.</span>
  368. <span class="comment">// All string values must be converted to []byte.</span>
  369. <span class="comment">//</span>
  370. <span class="comment">// Next should return io.EOF when there are no more rows.</span>
  371. Next(dest []<a href="index.html#Value">Value</a>) <a href="../../../builtin/index.html#error">error</a>
  372. }</pre>
  373. <p>
  374. Rows is an iterator over an executed query&#39;s results.
  375. </p>
  376. <h2 id="RowsAffected">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=6047:6070#L174">RowsAffected</a></h2>
  377. <pre>type RowsAffected <a href="../../../builtin/index.html#int64">int64</a></pre>
  378. <p>
  379. RowsAffected implements Result for an INSERT or UPDATE operation
  380. which mutates a number of rows.
  381. </p>
  382. <h3 id="RowsAffected.LastInsertId">func (RowsAffected) <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=6104:6153#L178">LastInsertId</a></h3>
  383. <pre>func (<a href="index.html#RowsAffected">RowsAffected</a>) LastInsertId() (<a href="../../../builtin/index.html#int64">int64</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  384. <h3 id="RowsAffected.RowsAffected">func (RowsAffected) <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=6210:6261#L182">RowsAffected</a></h3>
  385. <pre>func (v <a href="index.html#RowsAffected">RowsAffected</a>) RowsAffected() (<a href="../../../builtin/index.html#int64">int64</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  386. <h2 id="Stmt">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=3803:4638#L105">Stmt</a></h2>
  387. <pre>type Stmt interface {
  388. <span class="comment">// Close closes the statement.</span>
  389. <span class="comment">//</span>
  390. <span class="comment">// As of Go 1.1, a Stmt will not be closed if it&#39;s in use</span>
  391. <span class="comment">// by any queries.</span>
  392. Close() <a href="../../../builtin/index.html#error">error</a>
  393. <span class="comment">// NumInput returns the number of placeholder parameters.</span>
  394. <span class="comment">//</span>
  395. <span class="comment">// If NumInput returns &gt;= 0, the sql package will sanity check</span>
  396. <span class="comment">// argument counts from callers and return errors to the caller</span>
  397. <span class="comment">// before the statement&#39;s Exec or Query methods are called.</span>
  398. <span class="comment">//</span>
  399. <span class="comment">// NumInput may also return -1, if the driver doesn&#39;t know</span>
  400. <span class="comment">// its number of placeholders. In that case, the sql package</span>
  401. <span class="comment">// will not sanity check Exec or Query argument counts.</span>
  402. NumInput() <a href="../../../builtin/index.html#int">int</a>
  403. <span class="comment">// Exec executes a query that doesn&#39;t return rows, such</span>
  404. <span class="comment">// as an INSERT or UPDATE.</span>
  405. Exec(args []<a href="index.html#Value">Value</a>) (<a href="index.html#Result">Result</a>, <a href="../../../builtin/index.html#error">error</a>)
  406. <span class="comment">// Query executes a query that may return rows, such as a</span>
  407. <span class="comment">// SELECT.</span>
  408. Query(args []<a href="index.html#Value">Value</a>) (<a href="index.html#Rows">Rows</a>, <a href="../../../builtin/index.html#error">error</a>)
  409. }</pre>
  410. <p>
  411. Stmt is a prepared statement. It is bound to a Conn and not
  412. used by multiple goroutines concurrently.
  413. </p>
  414. <h2 id="Tx">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=5887:5942#L167">Tx</a></h2>
  415. <pre>type Tx interface {
  416. Commit() <a href="../../../builtin/index.html#error">error</a>
  417. Rollback() <a href="../../../builtin/index.html#error">error</a>
  418. }</pre>
  419. <p>
  420. Tx is a transaction.
  421. </p>
  422. <h2 id="Value">type <a href="http://localhost:6060/src/database/sql/driver/driver.go?s=566:588#L12">Value</a></h2>
  423. <pre>type Value interface{}</pre>
  424. <p>
  425. Value is a value that drivers must be able to handle.
  426. It is either nil or an instance of one of these types:
  427. </p>
  428. <pre>int64
  429. float64
  430. bool
  431. []byte
  432. string [*] everywhere except from Rows.Next.
  433. time.Time
  434. </pre>
  435. <h2 id="ValueConverter">type <a href="http://localhost:6060/src/database/sql/driver/types.go?s=928:1058#L20">ValueConverter</a></h2>
  436. <pre>type ValueConverter interface {
  437. <span class="comment">// ConvertValue converts a value to a driver Value.</span>
  438. ConvertValue(v interface{}) (<a href="index.html#Value">Value</a>, <a href="../../../builtin/index.html#error">error</a>)
  439. }</pre>
  440. <p>
  441. ValueConverter is the interface providing the ConvertValue method.
  442. </p>
  443. <p>
  444. Various implementations of ValueConverter are provided by the
  445. driver package to provide consistent implementations of conversions
  446. between drivers. The ValueConverters have several uses:
  447. </p>
  448. <pre>* converting from the Value types as provided by the sql package
  449. into a database table&#39;s specific column type and making sure it
  450. fits, such as making sure a particular int64 fits in a
  451. table&#39;s uint16 column.
  452. * converting a value as given from the database into one of the
  453. driver Value types.
  454. * by the sql package, for converting from a driver&#39;s Value type
  455. to a user&#39;s type in a scan.
  456. </pre>
  457. <h2 id="Valuer">type <a href="http://localhost:6060/src/database/sql/driver/types.go?s=1210:1293#L29">Valuer</a></h2>
  458. <pre>type Valuer interface {
  459. <span class="comment">// Value returns a driver Value.</span>
  460. Value() (<a href="index.html#Value">Value</a>, <a href="../../../builtin/index.html#error">error</a>)
  461. }</pre>
  462. <p>
  463. Valuer is the interface providing the Value method.
  464. </p>
  465. <p>
  466. Types implementing Valuer interface are able to convert
  467. themselves to a driver Value.
  468. </p>
  469. <div id="footer">
  470. Build version go1.6.<br>
  471. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  472. the content of this page is licensed under the
  473. Creative Commons Attribution 3.0 License,
  474. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  475. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  476. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  477. </div>
  478. </div><!-- .container -->
  479. </div><!-- #page -->
  480. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  481. <script type="text/javascript" src="../../../../lib/godoc/jquery.js"></script>
  482. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.js"></script>
  483. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.edit.js"></script>
  484. <script type="text/javascript" src="../../../../lib/godoc/godocs.js"></script>
  485. </body>
  486. </html>