overview.edoc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 client library
  16. @doc
  17. MySQL/OTP is a client library for connecting to MySQL databases from Erlang/OTP
  18. applications. 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 source code is available on the github page <a target="_top"
  21. href="https://github.com/mysql-otp/mysql-otp/">
  22. https://github.com/mysql-otp/mysql-otp/</a> along with a wiki and an issue
  23. tracker. Coverage reports from the EUnit tests are available <a target="_top"
  24. href="../.eunit/index.html">here</a>.
  25. This library is free software licensed under the GNU LGPL which allows you to
  26. use it in proprietary applications as well as free software applications with
  27. other licenses. This documentation is generated from the source code and thus
  28. goes under the same license as the library itself. The license files are
  29. available in the files <a href="../COPYING" target="_top">COPYING</a> and
  30. <a href="../COPYING.LESSER" target="_top">COPYING.LESSER</a>.
  31. <h2>API functions</h2>
  32. The <a href="mysql.html">mysql</a> module contains all the API functions for
  33. connecting to and interacting with a MySQL server.
  34. <h2 id="value-representation">Value representation</h2>
  35. <table>
  36. <thead>
  37. <tr>
  38. <th>MySQL</th>
  39. <th>Erlang</th>
  40. <th>Example</th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. <tr>
  45. <td>INT, TINYINT, etc.</td>
  46. <td>`integer()'</td>
  47. <td>`42'</td>
  48. </tr>
  49. <tr>
  50. <td>VARCHAR, TEXT, etc.</td>
  51. <td>`iodata()' [<a href="#vn1">1</a>]</td>
  52. <td>`<<"foo">>, "bar"'</td>
  53. </tr>
  54. <tr>
  55. <td>FLOAT, DOUBLE</td>
  56. <td>`float()'</td>
  57. <td>`3.14'</td>
  58. </tr>
  59. <tr>
  60. <td>DECIMAL</td>
  61. <td>`binary()' [<a href="#vn2">2</a>]</td>
  62. <td>`<<"3.140">>'</td>
  63. </tr>
  64. <tr>
  65. <td>DATETIME, TIMESTAMP</td>
  66. <td>`calendar:datetime()' [<a href="#vn3">3</a>]</td>
  67. <td>`{{2014, 11, 18}, {10, 22, 36}}'</td>
  68. </tr>
  69. <tr>
  70. <td>DATE</td>
  71. <td>`calendar:date()'</td>
  72. <td>`{2014, 11, 18}'</td>
  73. </tr>
  74. <tr>
  75. <td>TIME</td>
  76. <td>`{Days, calendar:time()}' [<a href="#vn3">3</a>,
  77. <a href="#vn4">4</a>]</td>
  78. <td>`{0, {10, 22, 36}}'</td>
  79. </tr>
  80. <tr>
  81. <td>NULL</td>
  82. <td>`null'</td>
  83. <td>`null'</td>
  84. </tr>
  85. </tbody>
  86. </table>
  87. Notes:
  88. <ol>
  89. <li id="vn1">When fetching VARCHAR, TEXT etc. they are returned as `binary()'.
  90. When sending (insert or update) any `iodata()' is accepted.</li>
  91. <li id="vn2">DECIMAL are currently always returned as `binary()'. This will
  92. probably be changed to something similar to how the `odbc' OTP application
  93. handles them, namely
  94. <ul>
  95. <li>`integer()' when there are no fractions;</li>
  96. <li>`float()' when the precision of a float is exact enough;</li>
  97. <li>`binary()' when the precision of a float is not enough.</li>
  98. </ul>
  99. </li>
  100. <li id="vn3">For `DATETIME', `TIMESTAMP' and `TIME' values with franctions of
  101. seconds, we use a float for the seconds part. (These are unusual and were
  102. added to MySQL in version 5.6.4.)</li>
  103. <li id="vn4">Since `TIME' can be outside the `calendar:time()' interval, we use
  104. the format as returned by calendar:seconds_to_daystime/1 for `TIME'
  105. values.</li>
  106. </ol>
  107. <h2>Example with Poolboy</h2>
  108. TODO