overview.edoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. MySQL/OTP – MySQL client library for Erlang/OTP
  2. Copyright (C) 2014 Viktor Söderqvist
  3. This file is part of MySQL/OTP.
  4. MySQL/OTP is free software: you can redistribute it and/or modify it under
  5. the terms of the GNU Lesser General Public License as published by the Free
  6. Software Foundation, either version 3 of the License, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. ------------------------------------------------------------------------
  15. @title MySQL/OTP User's Guide
  16. @doc
  17. MySQL/OTP is a driver for connecting Erlang/OTP applications to MySQL
  18. databases. It is a native implementation of the MySQL protocol in Erlang.
  19. This is the documentation generated from the Erlang source code using EDoc.
  20. The project page is on Gitbub:
  21. <a href="https://github.com/mysql-otp/mysql-otp/"
  22. target="_top">https://github.com/mysql-otp/mysql-otp/</a>.
  23. For the reference manual see the <a href="mysql.html">mysql</a> module.
  24. <h2 id="value-representation">Value representation</h2>
  25. <table>
  26. <thead>
  27. <tr>
  28. <th>MySQL</th>
  29. <th>Erlang</th>
  30. <th>Example</th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. <tr>
  35. <td>INT, TINYINT, etc.</td>
  36. <td>`integer()'</td>
  37. <td>`42'</td>
  38. </tr>
  39. <tr>
  40. <td>VARCHAR, TEXT, etc.</td>
  41. <td>`iodata()' [<a href="#vn1">1</a>]</td>
  42. <td>`<<"foo">>', `"bar"'</td>
  43. </tr>
  44. <tr>
  45. <td>BIT(N)</td>
  46. <td>`<<_:N/bitstring>>'</td>
  47. <td>`<<255, 6:3>>'</td>
  48. </tr>
  49. <tr>
  50. <td>FLOAT, DOUBLE</td>
  51. <td>`float()'</td>
  52. <td>`3.14'</td>
  53. </tr>
  54. <tr>
  55. <td>DECIMAL(P, S)</td>
  56. <td>`integer()' when S == 0<br />
  57. `float()' when P =&lt; 15 and S &gt; 0<br />
  58. `binary()' when P &gt;= 16 and S &gt; 0 [<a href="#vn2">2</a>]</td>
  59. <td>`42'<br />`3.14'<br />`<<"3.14159265358979323846">>'</td>
  60. </tr>
  61. <tr>
  62. <td>DATETIME, TIMESTAMP</td>
  63. <td>`calendar:datetime()' [<a href="#vn3">3</a>]</td>
  64. <td>`{{2014, 11, 18}, {10, 22, 36}}'</td>
  65. </tr>
  66. <tr>
  67. <td>DATE</td>
  68. <td>`calendar:date()'</td>
  69. <td>`{2014, 11, 18}'</td>
  70. </tr>
  71. <tr>
  72. <td>TIME</td>
  73. <td>`{Days, calendar:time()}' [<a href="#vn3">3</a>,
  74. <a href="#vn4">4</a>]</td>
  75. <td>`{0, {10, 22, 36}}'</td>
  76. </tr>
  77. <tr>
  78. <td>NULL</td>
  79. <td>`null'</td>
  80. <td>`null'</td>
  81. </tr>
  82. </tbody>
  83. </table>
  84. Notes:
  85. <ol>
  86. <li id="vn1">When fetching VARCHAR, TEXT etc. they are returned as `binary()'.
  87. When sending (insert or update) any `iodata()' is accepted.</li>
  88. <li id="vn2">DECIMALs are returned as `integer()' or `float()' when the value
  89. can be represented without precision loss and as `binary()' for high
  90. precision DECIMAL values. This is similar to how the `odbc' OTP application
  91. treats DECIMALs.</li>
  92. <li id="vn3">For `DATETIME', `TIMESTAMP' and `TIME' values with franctions of
  93. seconds, we use a float for the seconds part. (These are unusual and were
  94. added to MySQL in version 5.6.4.)</li>
  95. <li id="vn4">Since `TIME' can be outside the `calendar:time()' interval, we use
  96. the format as returned by `calendar:seconds_to_daystime/1' for `TIME'
  97. values.</li>
  98. </ol>
  99. <h2>Copying</h2>
  100. Copyright 2014 The authors of MySQL/OTP. See the project page at
  101. <a href="https://github.com/mysql-otp/mysql-otp"
  102. target="_top">https://github.com/mysql-otp/mysql-otp</a>.
  103. This library is free software licensed under the GNU LGPL which allows you to
  104. use it in proprietary applications as well as free software applications with
  105. other licenses. This documentation is generated from the source code and thus
  106. goes under the same license as the library itself.